Removed some unnecessary synchronizations from quest timers.

This commit is contained in:
MobiusDevelopment
2020-03-24 11:15:43 +00:00
parent 148a872859
commit 374eab6fdd
18 changed files with 647 additions and 807 deletions

View File

@@ -315,6 +315,7 @@ public class Quest extends AbstractScript implements IIdentifiable
return timer; return timer;
} }
} }
return null; return null;
} }
@@ -329,8 +330,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -344,9 +343,9 @@ public class Quest extends AbstractScript implements IIdentifiable
timer.cancel(); timer.cancel();
} }
} }
timers.clear(); timers.clear();
} }
}
/** /**
* Cancel the quest timer that matches the specified name and parameters. * Cancel the quest timer that matches the specified name and parameters.
@@ -361,8 +360,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -374,12 +371,10 @@ public class Quest extends AbstractScript implements IIdentifiable
if ((timer != null) && timer.equals(this, name, npc, player)) if ((timer != null) && timer.equals(this, name, npc, player))
{ {
timer.cancel(); timer.cancel();
timers.remove(timer);
return; return;
} }
} }
} }
}
/** /**
* Remove a quest timer from the list of all timers.<br> * Remove a quest timer from the list of all timers.<br>
@@ -393,15 +388,12 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(timer.toString()); final List<QuestTimer> timers = _questTimers.get(timer.toString());
if (timers != null) if (timers != null)
{ {
timers.remove(timer); timers.remove(timer);
} }
} }
}
// These are methods to call within the core to call the quest events. // These are methods to call within the core to call the quest events.
@@ -2813,21 +2805,20 @@ public class Quest extends AbstractScript implements IIdentifiable
public boolean unload(boolean removeFromList) public boolean unload(boolean removeFromList)
{ {
onSave(); onSave();
// cancel all pending timers before reloading.
// if timers ought to be restarted, the quest can take care of it // Cancel all pending timers before reloading.
// with its code (example: save global data indicating what timer must be restarted). // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted).
synchronized (_questTimers)
{
for (List<QuestTimer> timers : _questTimers.values()) for (List<QuestTimer> timers : _questTimers.values())
{ {
for (QuestTimer timer : timers) for (QuestTimer timer : timers)
{ {
timer.cancel(); timer.cancel();
} }
timers.clear(); timers.clear();
} }
_questTimers.clear(); _questTimers.clear();
}
if (removeFromList) if (removeFromList)
{ {

View File

@@ -317,6 +317,7 @@ public class Quest extends AbstractScript implements IIdentifiable
return timer; return timer;
} }
} }
return null; return null;
} }
@@ -331,8 +332,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -346,9 +345,9 @@ public class Quest extends AbstractScript implements IIdentifiable
timer.cancel(); timer.cancel();
} }
} }
timers.clear(); timers.clear();
} }
}
/** /**
* Cancel the quest timer that matches the specified name and parameters. * Cancel the quest timer that matches the specified name and parameters.
@@ -363,8 +362,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -376,12 +373,10 @@ public class Quest extends AbstractScript implements IIdentifiable
if ((timer != null) && timer.equals(this, name, npc, player)) if ((timer != null) && timer.equals(this, name, npc, player))
{ {
timer.cancel(); timer.cancel();
timers.remove(timer);
return; return;
} }
} }
} }
}
/** /**
* Remove a quest timer from the list of all timers.<br> * Remove a quest timer from the list of all timers.<br>
@@ -395,15 +390,12 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(timer.toString()); final List<QuestTimer> timers = _questTimers.get(timer.toString());
if (timers != null) if (timers != null)
{ {
timers.remove(timer); timers.remove(timer);
} }
} }
}
// These are methods to call within the core to call the quest events. // These are methods to call within the core to call the quest events.
@@ -2815,21 +2807,20 @@ public class Quest extends AbstractScript implements IIdentifiable
public boolean unload(boolean removeFromList) public boolean unload(boolean removeFromList)
{ {
onSave(); onSave();
// cancel all pending timers before reloading.
// if timers ought to be restarted, the quest can take care of it // Cancel all pending timers before reloading.
// with its code (example: save global data indicating what timer must be restarted). // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted).
synchronized (_questTimers)
{
for (List<QuestTimer> timers : _questTimers.values()) for (List<QuestTimer> timers : _questTimers.values())
{ {
for (QuestTimer timer : timers) for (QuestTimer timer : timers)
{ {
timer.cancel(); timer.cancel();
} }
timers.clear(); timers.clear();
} }
_questTimers.clear(); _questTimers.clear();
}
if (removeFromList) if (removeFromList)
{ {

View File

@@ -318,6 +318,7 @@ public class Quest extends AbstractScript implements IIdentifiable
return timer; return timer;
} }
} }
return null; return null;
} }
@@ -332,8 +333,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -347,9 +346,9 @@ public class Quest extends AbstractScript implements IIdentifiable
timer.cancel(); timer.cancel();
} }
} }
timers.clear(); timers.clear();
} }
}
/** /**
* Cancel the quest timer that matches the specified name and parameters. * Cancel the quest timer that matches the specified name and parameters.
@@ -364,8 +363,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -377,12 +374,10 @@ public class Quest extends AbstractScript implements IIdentifiable
if ((timer != null) && timer.equals(this, name, npc, player)) if ((timer != null) && timer.equals(this, name, npc, player))
{ {
timer.cancel(); timer.cancel();
timers.remove(timer);
return; return;
} }
} }
} }
}
/** /**
* Remove a quest timer from the list of all timers.<br> * Remove a quest timer from the list of all timers.<br>
@@ -396,15 +391,12 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(timer.toString()); final List<QuestTimer> timers = _questTimers.get(timer.toString());
if (timers != null) if (timers != null)
{ {
timers.remove(timer); timers.remove(timer);
} }
} }
}
// These are methods to call within the core to call the quest events. // These are methods to call within the core to call the quest events.
@@ -2816,21 +2808,20 @@ public class Quest extends AbstractScript implements IIdentifiable
public boolean unload(boolean removeFromList) public boolean unload(boolean removeFromList)
{ {
onSave(); onSave();
// cancel all pending timers before reloading.
// if timers ought to be restarted, the quest can take care of it // Cancel all pending timers before reloading.
// with its code (example: save global data indicating what timer must be restarted). // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted).
synchronized (_questTimers)
{
for (List<QuestTimer> timers : _questTimers.values()) for (List<QuestTimer> timers : _questTimers.values())
{ {
for (QuestTimer timer : timers) for (QuestTimer timer : timers)
{ {
timer.cancel(); timer.cancel();
} }
timers.clear(); timers.clear();
} }
_questTimers.clear(); _questTimers.clear();
}
if (removeFromList) if (removeFromList)
{ {

View File

@@ -318,6 +318,7 @@ public class Quest extends AbstractScript implements IIdentifiable
return timer; return timer;
} }
} }
return null; return null;
} }
@@ -332,8 +333,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -347,9 +346,9 @@ public class Quest extends AbstractScript implements IIdentifiable
timer.cancel(); timer.cancel();
} }
} }
timers.clear(); timers.clear();
} }
}
/** /**
* Cancel the quest timer that matches the specified name and parameters. * Cancel the quest timer that matches the specified name and parameters.
@@ -364,8 +363,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -377,12 +374,10 @@ public class Quest extends AbstractScript implements IIdentifiable
if ((timer != null) && timer.equals(this, name, npc, player)) if ((timer != null) && timer.equals(this, name, npc, player))
{ {
timer.cancel(); timer.cancel();
timers.remove(timer);
return; return;
} }
} }
} }
}
/** /**
* Remove a quest timer from the list of all timers.<br> * Remove a quest timer from the list of all timers.<br>
@@ -396,15 +391,12 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(timer.toString()); final List<QuestTimer> timers = _questTimers.get(timer.toString());
if (timers != null) if (timers != null)
{ {
timers.remove(timer); timers.remove(timer);
} }
} }
}
// These are methods to call within the core to call the quest events. // These are methods to call within the core to call the quest events.
@@ -2816,21 +2808,20 @@ public class Quest extends AbstractScript implements IIdentifiable
public boolean unload(boolean removeFromList) public boolean unload(boolean removeFromList)
{ {
onSave(); onSave();
// cancel all pending timers before reloading.
// if timers ought to be restarted, the quest can take care of it // Cancel all pending timers before reloading.
// with its code (example: save global data indicating what timer must be restarted). // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted).
synchronized (_questTimers)
{
for (List<QuestTimer> timers : _questTimers.values()) for (List<QuestTimer> timers : _questTimers.values())
{ {
for (QuestTimer timer : timers) for (QuestTimer timer : timers)
{ {
timer.cancel(); timer.cancel();
} }
timers.clear(); timers.clear();
} }
_questTimers.clear(); _questTimers.clear();
}
if (removeFromList) if (removeFromList)
{ {

View File

@@ -318,6 +318,7 @@ public class Quest extends AbstractScript implements IIdentifiable
return timer; return timer;
} }
} }
return null; return null;
} }
@@ -332,8 +333,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -347,9 +346,9 @@ public class Quest extends AbstractScript implements IIdentifiable
timer.cancel(); timer.cancel();
} }
} }
timers.clear(); timers.clear();
} }
}
/** /**
* Cancel the quest timer that matches the specified name and parameters. * Cancel the quest timer that matches the specified name and parameters.
@@ -364,8 +363,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -377,12 +374,10 @@ public class Quest extends AbstractScript implements IIdentifiable
if ((timer != null) && timer.equals(this, name, npc, player)) if ((timer != null) && timer.equals(this, name, npc, player))
{ {
timer.cancel(); timer.cancel();
timers.remove(timer);
return; return;
} }
} }
} }
}
/** /**
* Remove a quest timer from the list of all timers.<br> * Remove a quest timer from the list of all timers.<br>
@@ -396,15 +391,12 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(timer.toString()); final List<QuestTimer> timers = _questTimers.get(timer.toString());
if (timers != null) if (timers != null)
{ {
timers.remove(timer); timers.remove(timer);
} }
} }
}
// These are methods to call within the core to call the quest events. // These are methods to call within the core to call the quest events.
@@ -2816,21 +2808,20 @@ public class Quest extends AbstractScript implements IIdentifiable
public boolean unload(boolean removeFromList) public boolean unload(boolean removeFromList)
{ {
onSave(); onSave();
// cancel all pending timers before reloading.
// if timers ought to be restarted, the quest can take care of it // Cancel all pending timers before reloading.
// with its code (example: save global data indicating what timer must be restarted). // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted).
synchronized (_questTimers)
{
for (List<QuestTimer> timers : _questTimers.values()) for (List<QuestTimer> timers : _questTimers.values())
{ {
for (QuestTimer timer : timers) for (QuestTimer timer : timers)
{ {
timer.cancel(); timer.cancel();
} }
timers.clear(); timers.clear();
} }
_questTimers.clear(); _questTimers.clear();
}
if (removeFromList) if (removeFromList)
{ {

View File

@@ -318,6 +318,7 @@ public class Quest extends AbstractScript implements IIdentifiable
return timer; return timer;
} }
} }
return null; return null;
} }
@@ -332,8 +333,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -347,9 +346,9 @@ public class Quest extends AbstractScript implements IIdentifiable
timer.cancel(); timer.cancel();
} }
} }
timers.clear(); timers.clear();
} }
}
/** /**
* Cancel the quest timer that matches the specified name and parameters. * Cancel the quest timer that matches the specified name and parameters.
@@ -364,8 +363,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -377,12 +374,10 @@ public class Quest extends AbstractScript implements IIdentifiable
if ((timer != null) && timer.equals(this, name, npc, player)) if ((timer != null) && timer.equals(this, name, npc, player))
{ {
timer.cancel(); timer.cancel();
timers.remove(timer);
return; return;
} }
} }
} }
}
/** /**
* Remove a quest timer from the list of all timers.<br> * Remove a quest timer from the list of all timers.<br>
@@ -396,15 +391,12 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(timer.toString()); final List<QuestTimer> timers = _questTimers.get(timer.toString());
if (timers != null) if (timers != null)
{ {
timers.remove(timer); timers.remove(timer);
} }
} }
}
// These are methods to call within the core to call the quest events. // These are methods to call within the core to call the quest events.
@@ -2816,21 +2808,20 @@ public class Quest extends AbstractScript implements IIdentifiable
public boolean unload(boolean removeFromList) public boolean unload(boolean removeFromList)
{ {
onSave(); onSave();
// cancel all pending timers before reloading.
// if timers ought to be restarted, the quest can take care of it // Cancel all pending timers before reloading.
// with its code (example: save global data indicating what timer must be restarted). // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted).
synchronized (_questTimers)
{
for (List<QuestTimer> timers : _questTimers.values()) for (List<QuestTimer> timers : _questTimers.values())
{ {
for (QuestTimer timer : timers) for (QuestTimer timer : timers)
{ {
timer.cancel(); timer.cancel();
} }
timers.clear(); timers.clear();
} }
_questTimers.clear(); _questTimers.clear();
}
if (removeFromList) if (removeFromList)
{ {

View File

@@ -318,6 +318,7 @@ public class Quest extends AbstractScript implements IIdentifiable
return timer; return timer;
} }
} }
return null; return null;
} }
@@ -332,8 +333,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -347,9 +346,9 @@ public class Quest extends AbstractScript implements IIdentifiable
timer.cancel(); timer.cancel();
} }
} }
timers.clear(); timers.clear();
} }
}
/** /**
* Cancel the quest timer that matches the specified name and parameters. * Cancel the quest timer that matches the specified name and parameters.
@@ -364,8 +363,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -377,12 +374,10 @@ public class Quest extends AbstractScript implements IIdentifiable
if ((timer != null) && timer.equals(this, name, npc, player)) if ((timer != null) && timer.equals(this, name, npc, player))
{ {
timer.cancel(); timer.cancel();
timers.remove(timer);
return; return;
} }
} }
} }
}
/** /**
* Remove a quest timer from the list of all timers.<br> * Remove a quest timer from the list of all timers.<br>
@@ -396,15 +391,12 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(timer.toString()); final List<QuestTimer> timers = _questTimers.get(timer.toString());
if (timers != null) if (timers != null)
{ {
timers.remove(timer); timers.remove(timer);
} }
} }
}
// These are methods to call within the core to call the quest events. // These are methods to call within the core to call the quest events.
@@ -2816,21 +2808,20 @@ public class Quest extends AbstractScript implements IIdentifiable
public boolean unload(boolean removeFromList) public boolean unload(boolean removeFromList)
{ {
onSave(); onSave();
// cancel all pending timers before reloading.
// if timers ought to be restarted, the quest can take care of it // Cancel all pending timers before reloading.
// with its code (example: save global data indicating what timer must be restarted). // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted).
synchronized (_questTimers)
{
for (List<QuestTimer> timers : _questTimers.values()) for (List<QuestTimer> timers : _questTimers.values())
{ {
for (QuestTimer timer : timers) for (QuestTimer timer : timers)
{ {
timer.cancel(); timer.cancel();
} }
timers.clear(); timers.clear();
} }
_questTimers.clear(); _questTimers.clear();
}
if (removeFromList) if (removeFromList)
{ {

View File

@@ -328,6 +328,7 @@ public class Quest extends AbstractScript implements IIdentifiable
return timer; return timer;
} }
} }
return null; return null;
} }
@@ -342,8 +343,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -357,9 +356,9 @@ public class Quest extends AbstractScript implements IIdentifiable
timer.cancel(); timer.cancel();
} }
} }
timers.clear(); timers.clear();
} }
}
/** /**
* Cancel the quest timer that matches the specified name and parameters. * Cancel the quest timer that matches the specified name and parameters.
@@ -374,8 +373,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -387,12 +384,10 @@ public class Quest extends AbstractScript implements IIdentifiable
if ((timer != null) && timer.equals(this, name, npc, player)) if ((timer != null) && timer.equals(this, name, npc, player))
{ {
timer.cancel(); timer.cancel();
timers.remove(timer);
return; return;
} }
} }
} }
}
/** /**
* Remove a quest timer from the list of all timers.<br> * Remove a quest timer from the list of all timers.<br>
@@ -406,15 +401,12 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(timer.toString()); final List<QuestTimer> timers = _questTimers.get(timer.toString());
if (timers != null) if (timers != null)
{ {
timers.remove(timer); timers.remove(timer);
} }
} }
}
// These are methods to call within the core to call the quest events. // These are methods to call within the core to call the quest events.
@@ -2826,21 +2818,20 @@ public class Quest extends AbstractScript implements IIdentifiable
public boolean unload(boolean removeFromList) public boolean unload(boolean removeFromList)
{ {
onSave(); onSave();
// cancel all pending timers before reloading.
// if timers ought to be restarted, the quest can take care of it // Cancel all pending timers before reloading.
// with its code (example: save global data indicating what timer must be restarted). // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted).
synchronized (_questTimers)
{
for (List<QuestTimer> timers : _questTimers.values()) for (List<QuestTimer> timers : _questTimers.values())
{ {
for (QuestTimer timer : timers) for (QuestTimer timer : timers)
{ {
timer.cancel(); timer.cancel();
} }
timers.clear(); timers.clear();
} }
_questTimers.clear(); _questTimers.clear();
}
if (removeFromList) if (removeFromList)
{ {

View File

@@ -387,6 +387,7 @@ public class Quest extends ManagedScript
return timer; return timer;
} }
} }
return null; return null;
} }
@@ -401,8 +402,6 @@ public class Quest extends ManagedScript
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -416,9 +415,9 @@ public class Quest extends ManagedScript
timer.cancel(); timer.cancel();
} }
} }
timers.clear(); timers.clear();
} }
}
/** /**
* Cancel the quest timer that matches the specified name and parameters. * Cancel the quest timer that matches the specified name and parameters.
@@ -433,8 +432,6 @@ public class Quest extends ManagedScript
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -446,12 +443,10 @@ public class Quest extends ManagedScript
if ((timer != null) && timer.equals(this, name, npc, player)) if ((timer != null) && timer.equals(this, name, npc, player))
{ {
timer.cancel(); timer.cancel();
timers.remove(timer);
return; return;
} }
} }
} }
}
/** /**
* Remove a quest timer from the list of all timers.<br> * Remove a quest timer from the list of all timers.<br>
@@ -465,15 +460,12 @@ public class Quest extends ManagedScript
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(timer.toString()); final List<QuestTimer> timers = _questTimers.get(timer.toString());
if (timers != null) if (timers != null)
{ {
timers.remove(timer); timers.remove(timer);
} }
} }
}
// These are methods to call within the core to call the quest events. // These are methods to call within the core to call the quest events.
@@ -1668,20 +1660,21 @@ public class Quest extends ManagedScript
public boolean unload() public boolean unload()
{ {
saveGlobalData(); saveGlobalData();
// Cancel all pending timers before reloading. // Cancel all pending timers before reloading.
// If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted). // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted).
synchronized (_questTimers)
{
for (List<QuestTimer> timers : _questTimers.values()) for (List<QuestTimer> timers : _questTimers.values())
{ {
for (QuestTimer timer : timers) for (QuestTimer timer : timers)
{ {
timer.cancel(); timer.cancel();
} }
timers.clear(); timers.clear();
} }
_questTimers.clear(); _questTimers.clear();
}
return QuestManager.getInstance().removeQuest(this); return QuestManager.getInstance().removeQuest(this);
} }

View File

@@ -290,6 +290,7 @@ public class Quest extends AbstractScript implements IIdentifiable
return timer; return timer;
} }
} }
return null; return null;
} }
@@ -304,8 +305,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -319,9 +318,9 @@ public class Quest extends AbstractScript implements IIdentifiable
timer.cancel(); timer.cancel();
} }
} }
timers.clear(); timers.clear();
} }
}
/** /**
* Cancel the quest timer that matches the specified name and parameters. * Cancel the quest timer that matches the specified name and parameters.
@@ -336,8 +335,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -349,12 +346,10 @@ public class Quest extends AbstractScript implements IIdentifiable
if ((timer != null) && timer.equals(this, name, npc, player)) if ((timer != null) && timer.equals(this, name, npc, player))
{ {
timer.cancel(); timer.cancel();
timers.remove(timer);
return; return;
} }
} }
} }
}
/** /**
* Remove a quest timer from the list of all timers.<br> * Remove a quest timer from the list of all timers.<br>
@@ -368,15 +363,12 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(timer.toString()); final List<QuestTimer> timers = _questTimers.get(timer.toString());
if (timers != null) if (timers != null)
{ {
timers.remove(timer); timers.remove(timer);
} }
} }
}
// These are methods to call within the core to call the quest events. // These are methods to call within the core to call the quest events.
@@ -2503,21 +2495,20 @@ public class Quest extends AbstractScript implements IIdentifiable
public boolean unload(boolean removeFromList) public boolean unload(boolean removeFromList)
{ {
onSave(); onSave();
// cancel all pending timers before reloading.
// if timers ought to be restarted, the quest can take care of it // Cancel all pending timers before reloading.
// with its code (example: save global data indicating what timer must be restarted). // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted).
synchronized (_questTimers)
{
for (List<QuestTimer> timers : _questTimers.values()) for (List<QuestTimer> timers : _questTimers.values())
{ {
for (QuestTimer timer : timers) for (QuestTimer timer : timers)
{ {
timer.cancel(); timer.cancel();
} }
timers.clear(); timers.clear();
} }
_questTimers.clear(); _questTimers.clear();
}
if (removeFromList) if (removeFromList)
{ {

View File

@@ -292,6 +292,7 @@ public class Quest extends AbstractScript implements IIdentifiable
return timer; return timer;
} }
} }
return null; return null;
} }
@@ -306,8 +307,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -321,9 +320,9 @@ public class Quest extends AbstractScript implements IIdentifiable
timer.cancel(); timer.cancel();
} }
} }
timers.clear(); timers.clear();
} }
}
/** /**
* Cancel the quest timer that matches the specified name and parameters. * Cancel the quest timer that matches the specified name and parameters.
@@ -338,8 +337,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -351,12 +348,10 @@ public class Quest extends AbstractScript implements IIdentifiable
if ((timer != null) && timer.equals(this, name, npc, player)) if ((timer != null) && timer.equals(this, name, npc, player))
{ {
timer.cancel(); timer.cancel();
timers.remove(timer);
return; return;
} }
} }
} }
}
/** /**
* Remove a quest timer from the list of all timers.<br> * Remove a quest timer from the list of all timers.<br>
@@ -370,15 +365,12 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(timer.toString()); final List<QuestTimer> timers = _questTimers.get(timer.toString());
if (timers != null) if (timers != null)
{ {
timers.remove(timer); timers.remove(timer);
} }
} }
}
// These are methods to call within the core to call the quest events. // These are methods to call within the core to call the quest events.
@@ -2546,21 +2538,20 @@ public class Quest extends AbstractScript implements IIdentifiable
public boolean unload(boolean removeFromList) public boolean unload(boolean removeFromList)
{ {
onSave(); onSave();
// cancel all pending timers before reloading.
// if timers ought to be restarted, the quest can take care of it // Cancel all pending timers before reloading.
// with its code (example: save global data indicating what timer must be restarted). // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted).
synchronized (_questTimers)
{
for (List<QuestTimer> timers : _questTimers.values()) for (List<QuestTimer> timers : _questTimers.values())
{ {
for (QuestTimer timer : timers) for (QuestTimer timer : timers)
{ {
timer.cancel(); timer.cancel();
} }
timers.clear(); timers.clear();
} }
_questTimers.clear(); _questTimers.clear();
}
if (removeFromList) if (removeFromList)
{ {

View File

@@ -316,6 +316,7 @@ public class Quest extends AbstractScript implements IIdentifiable
return timer; return timer;
} }
} }
return null; return null;
} }
@@ -330,8 +331,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -345,9 +344,9 @@ public class Quest extends AbstractScript implements IIdentifiable
timer.cancel(); timer.cancel();
} }
} }
timers.clear(); timers.clear();
} }
}
/** /**
* Cancel the quest timer that matches the specified name and parameters. * Cancel the quest timer that matches the specified name and parameters.
@@ -362,8 +361,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -375,12 +372,10 @@ public class Quest extends AbstractScript implements IIdentifiable
if ((timer != null) && timer.equals(this, name, npc, player)) if ((timer != null) && timer.equals(this, name, npc, player))
{ {
timer.cancel(); timer.cancel();
timers.remove(timer);
return; return;
} }
} }
} }
}
/** /**
* Remove a quest timer from the list of all timers.<br> * Remove a quest timer from the list of all timers.<br>
@@ -394,15 +389,12 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(timer.toString()); final List<QuestTimer> timers = _questTimers.get(timer.toString());
if (timers != null) if (timers != null)
{ {
timers.remove(timer); timers.remove(timer);
} }
} }
}
// These are methods to call within the core to call the quest events. // These are methods to call within the core to call the quest events.
@@ -2770,21 +2762,20 @@ public class Quest extends AbstractScript implements IIdentifiable
public boolean unload(boolean removeFromList) public boolean unload(boolean removeFromList)
{ {
onSave(); onSave();
// cancel all pending timers before reloading.
// if timers ought to be restarted, the quest can take care of it // Cancel all pending timers before reloading.
// with its code (example: save global data indicating what timer must be restarted). // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted).
synchronized (_questTimers)
{
for (List<QuestTimer> timers : _questTimers.values()) for (List<QuestTimer> timers : _questTimers.values())
{ {
for (QuestTimer timer : timers) for (QuestTimer timer : timers)
{ {
timer.cancel(); timer.cancel();
} }
timers.clear(); timers.clear();
} }
_questTimers.clear(); _questTimers.clear();
}
if (removeFromList) if (removeFromList)
{ {

View File

@@ -316,6 +316,7 @@ public class Quest extends AbstractScript implements IIdentifiable
return timer; return timer;
} }
} }
return null; return null;
} }
@@ -330,8 +331,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -345,9 +344,9 @@ public class Quest extends AbstractScript implements IIdentifiable
timer.cancel(); timer.cancel();
} }
} }
timers.clear(); timers.clear();
} }
}
/** /**
* Cancel the quest timer that matches the specified name and parameters. * Cancel the quest timer that matches the specified name and parameters.
@@ -362,8 +361,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -375,12 +372,10 @@ public class Quest extends AbstractScript implements IIdentifiable
if ((timer != null) && timer.equals(this, name, npc, player)) if ((timer != null) && timer.equals(this, name, npc, player))
{ {
timer.cancel(); timer.cancel();
timers.remove(timer);
return; return;
} }
} }
} }
}
/** /**
* Remove a quest timer from the list of all timers.<br> * Remove a quest timer from the list of all timers.<br>
@@ -394,15 +389,12 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(timer.toString()); final List<QuestTimer> timers = _questTimers.get(timer.toString());
if (timers != null) if (timers != null)
{ {
timers.remove(timer); timers.remove(timer);
} }
} }
}
// These are methods to call within the core to call the quest events. // These are methods to call within the core to call the quest events.
@@ -2770,21 +2762,20 @@ public class Quest extends AbstractScript implements IIdentifiable
public boolean unload(boolean removeFromList) public boolean unload(boolean removeFromList)
{ {
onSave(); onSave();
// cancel all pending timers before reloading.
// if timers ought to be restarted, the quest can take care of it // Cancel all pending timers before reloading.
// with its code (example: save global data indicating what timer must be restarted). // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted).
synchronized (_questTimers)
{
for (List<QuestTimer> timers : _questTimers.values()) for (List<QuestTimer> timers : _questTimers.values())
{ {
for (QuestTimer timer : timers) for (QuestTimer timer : timers)
{ {
timer.cancel(); timer.cancel();
} }
timers.clear(); timers.clear();
} }
_questTimers.clear(); _questTimers.clear();
}
if (removeFromList) if (removeFromList)
{ {

View File

@@ -316,6 +316,7 @@ public class Quest extends AbstractScript implements IIdentifiable
return timer; return timer;
} }
} }
return null; return null;
} }
@@ -330,8 +331,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -345,9 +344,9 @@ public class Quest extends AbstractScript implements IIdentifiable
timer.cancel(); timer.cancel();
} }
} }
timers.clear(); timers.clear();
} }
}
/** /**
* Cancel the quest timer that matches the specified name and parameters. * Cancel the quest timer that matches the specified name and parameters.
@@ -362,8 +361,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -375,12 +372,10 @@ public class Quest extends AbstractScript implements IIdentifiable
if ((timer != null) && timer.equals(this, name, npc, player)) if ((timer != null) && timer.equals(this, name, npc, player))
{ {
timer.cancel(); timer.cancel();
timers.remove(timer);
return; return;
} }
} }
} }
}
/** /**
* Remove a quest timer from the list of all timers.<br> * Remove a quest timer from the list of all timers.<br>
@@ -394,15 +389,12 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(timer.toString()); final List<QuestTimer> timers = _questTimers.get(timer.toString());
if (timers != null) if (timers != null)
{ {
timers.remove(timer); timers.remove(timer);
} }
} }
}
// These are methods to call within the core to call the quest events. // These are methods to call within the core to call the quest events.
@@ -2770,21 +2762,20 @@ public class Quest extends AbstractScript implements IIdentifiable
public boolean unload(boolean removeFromList) public boolean unload(boolean removeFromList)
{ {
onSave(); onSave();
// cancel all pending timers before reloading.
// if timers ought to be restarted, the quest can take care of it // Cancel all pending timers before reloading.
// with its code (example: save global data indicating what timer must be restarted). // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted).
synchronized (_questTimers)
{
for (List<QuestTimer> timers : _questTimers.values()) for (List<QuestTimer> timers : _questTimers.values())
{ {
for (QuestTimer timer : timers) for (QuestTimer timer : timers)
{ {
timer.cancel(); timer.cancel();
} }
timers.clear(); timers.clear();
} }
_questTimers.clear(); _questTimers.clear();
}
if (removeFromList) if (removeFromList)
{ {

View File

@@ -316,6 +316,7 @@ public class Quest extends AbstractScript implements IIdentifiable
return timer; return timer;
} }
} }
return null; return null;
} }
@@ -330,8 +331,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -345,9 +344,9 @@ public class Quest extends AbstractScript implements IIdentifiable
timer.cancel(); timer.cancel();
} }
} }
timers.clear(); timers.clear();
} }
}
/** /**
* Cancel the quest timer that matches the specified name and parameters. * Cancel the quest timer that matches the specified name and parameters.
@@ -362,8 +361,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -375,12 +372,10 @@ public class Quest extends AbstractScript implements IIdentifiable
if ((timer != null) && timer.equals(this, name, npc, player)) if ((timer != null) && timer.equals(this, name, npc, player))
{ {
timer.cancel(); timer.cancel();
timers.remove(timer);
return; return;
} }
} }
} }
}
/** /**
* Remove a quest timer from the list of all timers.<br> * Remove a quest timer from the list of all timers.<br>
@@ -394,15 +389,12 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(timer.toString()); final List<QuestTimer> timers = _questTimers.get(timer.toString());
if (timers != null) if (timers != null)
{ {
timers.remove(timer); timers.remove(timer);
} }
} }
}
// These are methods to call within the core to call the quest events. // These are methods to call within the core to call the quest events.
@@ -2770,21 +2762,20 @@ public class Quest extends AbstractScript implements IIdentifiable
public boolean unload(boolean removeFromList) public boolean unload(boolean removeFromList)
{ {
onSave(); onSave();
// cancel all pending timers before reloading.
// if timers ought to be restarted, the quest can take care of it // Cancel all pending timers before reloading.
// with its code (example: save global data indicating what timer must be restarted). // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted).
synchronized (_questTimers)
{
for (List<QuestTimer> timers : _questTimers.values()) for (List<QuestTimer> timers : _questTimers.values())
{ {
for (QuestTimer timer : timers) for (QuestTimer timer : timers)
{ {
timer.cancel(); timer.cancel();
} }
timers.clear(); timers.clear();
} }
_questTimers.clear(); _questTimers.clear();
}
if (removeFromList) if (removeFromList)
{ {

View File

@@ -316,6 +316,7 @@ public class Quest extends AbstractScript implements IIdentifiable
return timer; return timer;
} }
} }
return null; return null;
} }
@@ -330,8 +331,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -345,9 +344,9 @@ public class Quest extends AbstractScript implements IIdentifiable
timer.cancel(); timer.cancel();
} }
} }
timers.clear(); timers.clear();
} }
}
/** /**
* Cancel the quest timer that matches the specified name and parameters. * Cancel the quest timer that matches the specified name and parameters.
@@ -362,8 +361,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -375,12 +372,10 @@ public class Quest extends AbstractScript implements IIdentifiable
if ((timer != null) && timer.equals(this, name, npc, player)) if ((timer != null) && timer.equals(this, name, npc, player))
{ {
timer.cancel(); timer.cancel();
timers.remove(timer);
return; return;
} }
} }
} }
}
/** /**
* Remove a quest timer from the list of all timers.<br> * Remove a quest timer from the list of all timers.<br>
@@ -394,15 +389,12 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(timer.toString()); final List<QuestTimer> timers = _questTimers.get(timer.toString());
if (timers != null) if (timers != null)
{ {
timers.remove(timer); timers.remove(timer);
} }
} }
}
// These are methods to call within the core to call the quest events. // These are methods to call within the core to call the quest events.
@@ -2770,21 +2762,20 @@ public class Quest extends AbstractScript implements IIdentifiable
public boolean unload(boolean removeFromList) public boolean unload(boolean removeFromList)
{ {
onSave(); onSave();
// cancel all pending timers before reloading.
// if timers ought to be restarted, the quest can take care of it // Cancel all pending timers before reloading.
// with its code (example: save global data indicating what timer must be restarted). // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted).
synchronized (_questTimers)
{
for (List<QuestTimer> timers : _questTimers.values()) for (List<QuestTimer> timers : _questTimers.values())
{ {
for (QuestTimer timer : timers) for (QuestTimer timer : timers)
{ {
timer.cancel(); timer.cancel();
} }
timers.clear(); timers.clear();
} }
_questTimers.clear(); _questTimers.clear();
}
if (removeFromList) if (removeFromList)
{ {

View File

@@ -316,6 +316,7 @@ public class Quest extends AbstractScript implements IIdentifiable
return timer; return timer;
} }
} }
return null; return null;
} }
@@ -330,8 +331,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -345,9 +344,9 @@ public class Quest extends AbstractScript implements IIdentifiable
timer.cancel(); timer.cancel();
} }
} }
timers.clear(); timers.clear();
} }
}
/** /**
* Cancel the quest timer that matches the specified name and parameters. * Cancel the quest timer that matches the specified name and parameters.
@@ -362,8 +361,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -375,12 +372,10 @@ public class Quest extends AbstractScript implements IIdentifiable
if ((timer != null) && timer.equals(this, name, npc, player)) if ((timer != null) && timer.equals(this, name, npc, player))
{ {
timer.cancel(); timer.cancel();
timers.remove(timer);
return; return;
} }
} }
} }
}
/** /**
* Remove a quest timer from the list of all timers.<br> * Remove a quest timer from the list of all timers.<br>
@@ -394,15 +389,12 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(timer.toString()); final List<QuestTimer> timers = _questTimers.get(timer.toString());
if (timers != null) if (timers != null)
{ {
timers.remove(timer); timers.remove(timer);
} }
} }
}
// These are methods to call within the core to call the quest events. // These are methods to call within the core to call the quest events.
@@ -2770,21 +2762,20 @@ public class Quest extends AbstractScript implements IIdentifiable
public boolean unload(boolean removeFromList) public boolean unload(boolean removeFromList)
{ {
onSave(); onSave();
// cancel all pending timers before reloading.
// if timers ought to be restarted, the quest can take care of it // Cancel all pending timers before reloading.
// with its code (example: save global data indicating what timer must be restarted). // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted).
synchronized (_questTimers)
{
for (List<QuestTimer> timers : _questTimers.values()) for (List<QuestTimer> timers : _questTimers.values())
{ {
for (QuestTimer timer : timers) for (QuestTimer timer : timers)
{ {
timer.cancel(); timer.cancel();
} }
timers.clear(); timers.clear();
} }
_questTimers.clear(); _questTimers.clear();
}
if (removeFromList) if (removeFromList)
{ {

View File

@@ -316,6 +316,7 @@ public class Quest extends AbstractScript implements IIdentifiable
return timer; return timer;
} }
} }
return null; return null;
} }
@@ -330,8 +331,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -345,9 +344,9 @@ public class Quest extends AbstractScript implements IIdentifiable
timer.cancel(); timer.cancel();
} }
} }
timers.clear(); timers.clear();
} }
}
/** /**
* Cancel the quest timer that matches the specified name and parameters. * Cancel the quest timer that matches the specified name and parameters.
@@ -362,8 +361,6 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(name); final List<QuestTimer> timers = _questTimers.get(name);
if ((timers == null) || timers.isEmpty()) if ((timers == null) || timers.isEmpty())
{ {
@@ -375,12 +372,10 @@ public class Quest extends AbstractScript implements IIdentifiable
if ((timer != null) && timer.equals(this, name, npc, player)) if ((timer != null) && timer.equals(this, name, npc, player))
{ {
timer.cancel(); timer.cancel();
timers.remove(timer);
return; return;
} }
} }
} }
}
/** /**
* Remove a quest timer from the list of all timers.<br> * Remove a quest timer from the list of all timers.<br>
@@ -394,15 +389,12 @@ public class Quest extends AbstractScript implements IIdentifiable
return; return;
} }
synchronized (_questTimers)
{
final List<QuestTimer> timers = _questTimers.get(timer.toString()); final List<QuestTimer> timers = _questTimers.get(timer.toString());
if (timers != null) if (timers != null)
{ {
timers.remove(timer); timers.remove(timer);
} }
} }
}
// These are methods to call within the core to call the quest events. // These are methods to call within the core to call the quest events.
@@ -2770,21 +2762,20 @@ public class Quest extends AbstractScript implements IIdentifiable
public boolean unload(boolean removeFromList) public boolean unload(boolean removeFromList)
{ {
onSave(); onSave();
// cancel all pending timers before reloading.
// if timers ought to be restarted, the quest can take care of it // Cancel all pending timers before reloading.
// with its code (example: save global data indicating what timer must be restarted). // If timers ought to be restarted, the quest can take care of it with its code (example: save global data indicating what timer must be restarted).
synchronized (_questTimers)
{
for (List<QuestTimer> timers : _questTimers.values()) for (List<QuestTimer> timers : _questTimers.values())
{ {
for (QuestTimer timer : timers) for (QuestTimer timer : timers)
{ {
timer.cancel(); timer.cancel();
} }
timers.clear(); timers.clear();
} }
_questTimers.clear(); _questTimers.clear();
}
if (removeFromList) if (removeFromList)
{ {