Changed getAi method to synchronized.

This commit is contained in:
MobiusDevelopment
2019-11-03 20:52:05 +00:00
parent fb5302e0ab
commit 3ed4660df9
18 changed files with 39 additions and 148 deletions
@@ -1778,18 +1778,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
* Gets this creature's AI.
* @return the AI
*/
public CreatureAI getAI()
public synchronized CreatureAI getAI()
{
CreatureAI ai = _ai;
if (ai == null)
{
synchronized (this)
{
if (_ai == null)
{
return _ai = initAI();
}
}
_ai = ai = initAI();
}
return ai;
}
@@ -1778,18 +1778,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
* Gets this creature's AI.
* @return the AI
*/
public CreatureAI getAI()
public synchronized CreatureAI getAI()
{
CreatureAI ai = _ai;
if (ai == null)
{
synchronized (this)
{
if (_ai == null)
{
return _ai = initAI();
}
}
_ai = ai = initAI();
}
return ai;
}
@@ -1778,18 +1778,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
* Gets this creature's AI.
* @return the AI
*/
public CreatureAI getAI()
public synchronized CreatureAI getAI()
{
CreatureAI ai = _ai;
if (ai == null)
{
synchronized (this)
{
if (_ai == null)
{
return _ai = initAI();
}
}
_ai = ai = initAI();
}
return ai;
}
@@ -1778,18 +1778,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
* Gets this creature's AI.
* @return the AI
*/
public CreatureAI getAI()
public synchronized CreatureAI getAI()
{
CreatureAI ai = _ai;
if (ai == null)
{
synchronized (this)
{
if (_ai == null)
{
return _ai = initAI();
}
}
_ai = ai = initAI();
}
return ai;
}
@@ -1778,18 +1778,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
* Gets this creature's AI.
* @return the AI
*/
public CreatureAI getAI()
public synchronized CreatureAI getAI()
{
CreatureAI ai = _ai;
if (ai == null)
{
synchronized (this)
{
if (_ai == null)
{
return _ai = initAI();
}
}
_ai = ai = initAI();
}
return ai;
}
@@ -1778,18 +1778,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
* Gets this creature's AI.
* @return the AI
*/
public CreatureAI getAI()
public synchronized CreatureAI getAI()
{
CreatureAI ai = _ai;
if (ai == null)
{
synchronized (this)
{
if (_ai == null)
{
return _ai = initAI();
}
}
_ai = ai = initAI();
}
return ai;
}
@@ -1778,18 +1778,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
* Gets this creature's AI.
* @return the AI
*/
public CreatureAI getAI()
public synchronized CreatureAI getAI()
{
CreatureAI ai = _ai;
if (ai == null)
{
synchronized (this)
{
if (_ai == null)
{
return _ai = initAI();
}
}
_ai = ai = initAI();
}
return ai;
}
@@ -1778,18 +1778,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
* Gets this creature's AI.
* @return the AI
*/
public CreatureAI getAI()
public synchronized CreatureAI getAI()
{
CreatureAI ai = _ai;
if (ai == null)
{
synchronized (this)
{
if (_ai == null)
{
return _ai = initAI();
}
}
_ai = ai = initAI();
}
return ai;
}
@@ -2240,21 +2240,15 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
}
/**
* Return the CreatureAI of the Creature and if its null create a new one.
* @return the aI
* Gets this creature's AI.
* @return the AI
*/
public CreatureAI getAI()
public synchronized CreatureAI getAI()
{
CreatureAI ai = _ai;
if (ai == null)
{
synchronized (this)
{
if (_ai == null)
{
_ai = new CreatureAI(new AIAccessor());
}
}
_ai = ai = new CreatureAI(new AIAccessor());
}
return ai;
}
@@ -2265,8 +2259,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
*/
public void setAI(CreatureAI newAI)
{
CreatureAI oldAI = getAI();
CreatureAI oldAI = _ai;
if ((oldAI != null) && (oldAI != newAI) && (oldAI instanceof AttackableAI))
{
((AttackableAI) oldAI).stopAITask();
@@ -2534,18 +2534,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
* Gets this creature's AI.
* @return the AI
*/
public CreatureAI getAI()
public synchronized CreatureAI getAI()
{
CreatureAI ai = _ai;
if (ai == null)
{
synchronized (this)
{
if (_ai == null)
{
return _ai = initAI();
}
}
_ai = ai = initAI();
}
return ai;
}
@@ -2536,18 +2536,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
* Gets this creature's AI.
* @return the AI
*/
public CreatureAI getAI()
public synchronized CreatureAI getAI()
{
CreatureAI ai = _ai;
if (ai == null)
{
synchronized (this)
{
if (_ai == null)
{
return _ai = initAI();
}
}
_ai = ai = initAI();
}
return ai;
}
@@ -1777,18 +1777,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
* Gets this creature's AI.
* @return the AI
*/
public CreatureAI getAI()
public synchronized CreatureAI getAI()
{
CreatureAI ai = _ai;
if (ai == null)
{
synchronized (this)
{
if (_ai == null)
{
return _ai = initAI();
}
}
_ai = ai = initAI();
}
return ai;
}
@@ -1777,18 +1777,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
* Gets this creature's AI.
* @return the AI
*/
public CreatureAI getAI()
public synchronized CreatureAI getAI()
{
CreatureAI ai = _ai;
if (ai == null)
{
synchronized (this)
{
if (_ai == null)
{
return _ai = initAI();
}
}
_ai = ai = initAI();
}
return ai;
}
@@ -1777,18 +1777,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
* Gets this creature's AI.
* @return the AI
*/
public CreatureAI getAI()
public synchronized CreatureAI getAI()
{
CreatureAI ai = _ai;
if (ai == null)
{
synchronized (this)
{
if (_ai == null)
{
return _ai = initAI();
}
}
_ai = ai = initAI();
}
return ai;
}
@@ -1778,18 +1778,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
* Gets this creature's AI.
* @return the AI
*/
public CreatureAI getAI()
public synchronized CreatureAI getAI()
{
CreatureAI ai = _ai;
if (ai == null)
{
synchronized (this)
{
if (_ai == null)
{
return _ai = initAI();
}
}
_ai = ai = initAI();
}
return ai;
}
@@ -1778,18 +1778,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
* Gets this creature's AI.
* @return the AI
*/
public CreatureAI getAI()
public synchronized CreatureAI getAI()
{
CreatureAI ai = _ai;
if (ai == null)
{
synchronized (this)
{
if (_ai == null)
{
return _ai = initAI();
}
}
_ai = ai = initAI();
}
return ai;
}
@@ -1778,18 +1778,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
* Gets this creature's AI.
* @return the AI
*/
public CreatureAI getAI()
public synchronized CreatureAI getAI()
{
CreatureAI ai = _ai;
if (ai == null)
{
synchronized (this)
{
if (_ai == null)
{
return _ai = initAI();
}
}
_ai = ai = initAI();
}
return ai;
}
@@ -1777,18 +1777,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
* Gets this creature's AI.
* @return the AI
*/
public CreatureAI getAI()
public synchronized CreatureAI getAI()
{
CreatureAI ai = _ai;
if (ai == null)
{
synchronized (this)
{
if (_ai == null)
{
return _ai = initAI();
}
}
_ai = ai = initAI();
}
return ai;
}