Method isVisible should be named isSpawned to reflect what it does.

This commit is contained in:
MobiusDevelopment
2020-07-11 07:16:59 +00:00
parent 0ac09f876f
commit ae2e9409c6
54 changed files with 102 additions and 114 deletions

View File

@@ -152,7 +152,7 @@ abstract class AbstractAI implements Ctrl
@Override @Override
public void setIntention(CtrlIntention intention, Object arg0, Object arg1) public void setIntention(CtrlIntention intention, Object arg0, Object arg1)
{ {
if (!_actor.isVisible() || !_actor.hasAI()) if (!_actor.isSpawned() || !_actor.hasAI())
{ {
return; return;
} }
@@ -252,7 +252,7 @@ abstract class AbstractAI implements Ctrl
@Override @Override
public void notifyEvent(CtrlEvent evt, Object arg0, Object arg1) public void notifyEvent(CtrlEvent evt, Object arg0, Object arg1)
{ {
if (!_actor.isVisible() || !_actor.hasAI() || ((_actor instanceof PlayerInstance) && !((PlayerInstance) _actor).isOnline()) || ((_actor instanceof PlayerInstance) && ((PlayerInstance) _actor).isInOfflineMode())) if (!_actor.isSpawned() || !_actor.hasAI() || ((_actor instanceof PlayerInstance) && !((PlayerInstance) _actor).isOnline()) || ((_actor instanceof PlayerInstance) && ((PlayerInstance) _actor).isInOfflineMode()))
{ {
return; return;
} }

View File

@@ -823,7 +823,7 @@ public class FortSiegeGuardAI extends CreatureAI implements Runnable
@Override @Override
public void onEvtThink() public void onEvtThink()
{ {
// if(getIntention() != AI_INTENTION_IDLE && (!_actor.isVisible() || !_actor.hasAI() || !_actor.isKnownPlayers())) // if(getIntention() != AI_INTENTION_IDLE && (!_actor.isSpawned() || !_actor.hasAI() || !_actor.isKnownPlayers()))
// setIntention(AI_INTENTION_IDLE); // setIntention(AI_INTENTION_IDLE);
// Check if the actor can't use skills and if a thinking action isn't already in progress // Check if the actor can't use skills and if a thinking action isn't already in progress

View File

@@ -69,7 +69,7 @@ public class Resurrect implements ISkillHandler
} }
} }
if (target.isVisible()) if (target.isSpawned())
{ {
targetToRes.add(target); targetToRes.add(target);
} }

View File

@@ -252,7 +252,7 @@ public class DayNightSpawnManager
} }
case 1: case 1:
{ {
if (!boss.isVisible()) if (!boss.isSpawned())
{ {
boss.spawnMe(); boss.spawnMe();
} }

View File

@@ -131,7 +131,7 @@ public class ItemsOnGroundManager
item.getPosition().getWorldRegion().addVisibleObject(item); item.getPosition().getWorldRegion().addVisibleObject(item);
item.setDropTime(result.getLong(8)); item.setDropTime(result.getLong(8));
item.setProtected(result.getLong(8) == -1); item.setProtected(result.getLong(8) == -1);
item.setVisible(true); item.setSpawned(true);
World.getInstance().addVisibleObject(item, item.getPosition().getWorldRegion(), null); World.getInstance().addVisibleObject(item, item.getPosition().getWorldRegion(), null);
_items.add(item); _items.add(item);
count++; count++;

View File

@@ -119,7 +119,7 @@ public class ObjectPosition
} }
setWorldPosition(correctX, correctY, z); setWorldPosition(correctX, correctY, z);
_activeObject.setVisible(false); _activeObject.setSpawned(false);
} }
/** /**
@@ -127,7 +127,7 @@ public class ObjectPosition
*/ */
public void updateWorldRegion() public void updateWorldRegion()
{ {
if (!_activeObject.isVisible()) if (!_activeObject.isSpawned())
{ {
return; return;
} }

View File

@@ -503,7 +503,7 @@ public class World
continue; // skip our own character continue; // skip our own character
} }
if (!wo.isVisible()) if (!wo.isSpawned())
{ {
continue; // skip dying objects continue; // skip dying objects
} }
@@ -533,7 +533,7 @@ public class World
*/ */
public List<WorldObject> getVisibleObjects(WorldObject object, int radius) public List<WorldObject> getVisibleObjects(WorldObject object, int radius)
{ {
if ((object == null) || !object.isVisible()) if ((object == null) || !object.isSpawned())
{ {
return Collections.emptyList(); return Collections.emptyList();
} }
@@ -600,7 +600,7 @@ public class World
*/ */
public List<WorldObject> getVisibleObjects3D(WorldObject object, int radius) public List<WorldObject> getVisibleObjects3D(WorldObject object, int radius)
{ {
if ((object == null) || !object.isVisible()) if ((object == null) || !object.isSpawned())
{ {
return Collections.emptyList(); return Collections.emptyList();
} }
@@ -684,7 +684,7 @@ public class World
continue; // skip our own character continue; // skip our own character
} }
if (!playable.isVisible()) if (!playable.isSpawned())
{ {
continue; // skip dying objects continue; // skip dying objects
} }

View File

@@ -42,7 +42,7 @@ public abstract class WorldObject
{ {
private static final Logger LOGGER = Logger.getLogger(WorldObject.class.getName()); private static final Logger LOGGER = Logger.getLogger(WorldObject.class.getName());
private boolean _visible; private boolean _isSpawned;
private WorldObjectKnownList _knownList; private WorldObjectKnownList _knownList;
private String _name; private String _name;
private int _objectId; private int _objectId;
@@ -134,7 +134,7 @@ public abstract class WorldObject
public void decayMe() public void decayMe()
{ {
// Remove the WorldObject from the world // Remove the WorldObject from the world
_visible = false; _isSpawned = false;
World.getInstance().removeVisibleObject(this, getPosition().getWorldRegion()); World.getInstance().removeVisibleObject(this, getPosition().getWorldRegion());
World.getInstance().removeObject(this); World.getInstance().removeObject(this);
getPosition().setWorldRegion(null); getPosition().setWorldRegion(null);
@@ -170,7 +170,7 @@ public abstract class WorldObject
synchronized (this) synchronized (this)
{ {
_visible = false; _isSpawned = false;
getPosition().setWorldRegion(null); getPosition().setWorldRegion(null);
} }
@@ -218,7 +218,7 @@ public abstract class WorldObject
synchronized (this) synchronized (this)
{ {
// Set the x,y,z position of the WorldObject spawn and update its _worldregion // Set the x,y,z position of the WorldObject spawn and update its _worldregion
_visible = true; _isSpawned = true;
getPosition().setWorldRegion(World.getInstance().getRegion(getPosition().getWorldPosition())); getPosition().setWorldRegion(World.getInstance().getRegion(getPosition().getWorldPosition()));
// Add the WorldObject spawn in the _allobjects of World // Add the WorldObject spawn in the _allobjects of World
@@ -239,7 +239,7 @@ public abstract class WorldObject
synchronized (this) synchronized (this)
{ {
// Set the x,y,z position of the WorldObject spawn and update its _worldregion // Set the x,y,z position of the WorldObject spawn and update its _worldregion
_visible = true; _isSpawned = true;
int spawnX = x; int spawnX = x;
if (spawnX > World.MAP_MAX_X) if (spawnX > World.MAP_MAX_X)
@@ -288,7 +288,7 @@ public abstract class WorldObject
public void toggleVisible() public void toggleVisible()
{ {
if (isVisible()) if (isSpawned())
{ {
decayMe(); decayMe();
} }
@@ -300,21 +300,15 @@ public abstract class WorldObject
public abstract boolean isAutoAttackable(Creature attacker); public abstract boolean isAutoAttackable(Creature attacker);
/** public boolean isSpawned()
* <b><u>Concept</u>:</b><br>
* <br>
* A WorldObject is visible if <b>__IsVisible</b>=true and <b>_worldregion</b>!=null
* @return the visibility state of the WorldObject.
*/
public boolean isVisible()
{ {
return getPosition().getWorldRegion() != null; return getPosition().getWorldRegion() != null;
} }
public void setVisible(boolean value) public void setSpawned(boolean value)
{ {
_visible = value; _isSpawned = value;
if (!_visible) if (!_isSpawned)
{ {
getPosition().setWorldRegion(null); getPosition().setWorldRegion(null);
} }
@@ -387,7 +381,7 @@ public abstract class WorldObject
_instanceId = instanceId; _instanceId = instanceId;
// If we change it for visible objects, me must clear & revalidates knownlists // If we change it for visible objects, me must clear & revalidates knownlists
if (_visible && (_knownList != null)) if (_isSpawned && (_knownList != null))
{ {
if (this instanceof PlayerInstance) if (this instanceof PlayerInstance)
{ {

View File

@@ -1104,7 +1104,7 @@ public class Attackable extends NpcInstance
continue; continue;
} }
if (ai._attacker.isAlikeDead() || !getKnownList().knowsObject(ai._attacker) || !ai._attacker.isVisible() || ((ai._attacker instanceof PlayerInstance) && !((PlayerInstance) ai._attacker).isOnline() && !((PlayerInstance) ai._attacker).isInOfflineMode())) if (ai._attacker.isAlikeDead() || !getKnownList().knowsObject(ai._attacker) || !ai._attacker.isSpawned() || ((ai._attacker instanceof PlayerInstance) && !((PlayerInstance) ai._attacker).isOnline() && !((PlayerInstance) ai._attacker).isInOfflineMode()))
{ {
ai._hate = 0; ai._hate = 0;
} }
@@ -1155,7 +1155,7 @@ public class Attackable extends NpcInstance
return 0; return 0;
} }
if (!ai._attacker.isVisible()) if (!ai._attacker.isSpawned())
{ {
_aggroList.remove(target); _aggroList.remove(target);
return 0; return 0;

View File

@@ -5145,7 +5145,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
return true; return true;
} }
if (!isVisible()) if (!isSpawned())
{ {
_move = null; _move = null;
return true; return true;
@@ -5361,7 +5361,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
public void setTarget(WorldObject worldObject) public void setTarget(WorldObject worldObject)
{ {
WorldObject object = worldObject; WorldObject object = worldObject;
if ((object != null) && !object.isVisible()) if ((object != null) && !object.isSpawned())
{ {
object = null; object = null;
} }

View File

@@ -384,7 +384,7 @@ public abstract class Summon extends Playable
{ {
super.broadcastStatusUpdate(); super.broadcastStatusUpdate();
if ((_owner != null) && isVisible()) if ((_owner != null) && isSpawned())
{ {
_owner.sendPacket(new PetStatusUpdate(this)); _owner.sendPacket(new PetStatusUpdate(this));
} }
@@ -404,7 +404,7 @@ public abstract class Summon extends Playable
public synchronized void unSummon(PlayerInstance owner) public synchronized void unSummon(PlayerInstance owner)
{ {
if (isVisible() && !isDead()) if (isSpawned() && !isDead())
{ {
stopAllEffects(); stopAllEffects();

View File

@@ -153,7 +153,7 @@ public class CabaleBufferInstance extends NpcInstance
private boolean handleCast(PlayerInstance player, int skillId) private boolean handleCast(PlayerInstance player, int skillId)
{ {
final int skillLevel = player.getLevel() > 40 ? 1 : 2; final int skillLevel = player.getLevel() > 40 ? 1 : 2;
if (player.isDead() || !player.isVisible() || !isInsideRadius(player, getDistanceToWatchObject(player), false, false)) if (player.isDead() || !player.isSpawned() || !isInsideRadius(player, getDistanceToWatchObject(player), false, false))
{ {
return false; return false;
} }

View File

@@ -204,7 +204,7 @@ public class ChestInstance extends MonsterInstance
skillLevel = 6; skillLevel = 6;
} }
if (creature.isDead() || !creature.isVisible() || !creature.isInsideRadius(this, getDistanceToWatchObject(creature), false, false)) if (creature.isDead() || !creature.isSpawned() || !creature.isInsideRadius(this, getDistanceToWatchObject(creature), false, false))
{ {
return false; return false;
} }

View File

@@ -453,7 +453,7 @@ public class CubicInstance
{ {
targetIt = false; targetIt = false;
} }
if (!enemy.isVisible()) if (!enemy.isSpawned())
{ {
targetIt = false; targetIt = false;
} }

View File

@@ -476,7 +476,7 @@ public class PetInstance extends Summon
synchronized (target) synchronized (target)
{ {
if (!target.isVisible()) if (!target.isSpawned())
{ {
getOwner().sendPacket(ActionFailed.STATIC_PACKET); getOwner().sendPacket(ActionFailed.STATIC_PACKET);
return; return;

View File

@@ -5100,7 +5100,7 @@ public class PlayerInstance extends Playable
synchronized (target) synchronized (target)
{ {
// Check if the target to pick up is visible // Check if the target to pick up is visible
if (!target.isVisible()) if (!target.isSpawned())
{ {
// Send a Server->Client packet ActionFailed to this PlayerInstance // Send a Server->Client packet ActionFailed to this PlayerInstance
sendPacket(ActionFailed.STATIC_PACKET); sendPacket(ActionFailed.STATIC_PACKET);
@@ -5267,7 +5267,7 @@ public class PlayerInstance extends Playable
{ {
// Check if the new target is visible // Check if the new target is visible
WorldObject newTarget = worldObject; WorldObject newTarget = worldObject;
if ((newTarget != null) && !newTarget.isVisible()) if ((newTarget != null) && !newTarget.isSpawned())
{ {
newTarget = null; newTarget = null;
} }
@@ -12729,7 +12729,7 @@ public class PlayerInstance extends Playable
return true; return true;
} }
if (!isVisible()) if (!isSpawned())
{ {
_move = null; _move = null;
return true; return true;
@@ -13507,7 +13507,7 @@ public class PlayerInstance extends Playable
} }
// Remove the PlayerInstance from the world // Remove the PlayerInstance from the world
if (isVisible()) if (isSpawned())
{ {
try try
{ {

View File

@@ -75,7 +75,7 @@ public class ProtectorInstance extends NpcInstance
// Cast for Player // Cast for Player
private boolean handleCast(PlayerInstance player, int skillId, int skillLevel) private boolean handleCast(PlayerInstance player, int skillId, int skillLevel)
{ {
if (player.isGM() || player.isDead() || !player.isVisible() || !isInsideRadius(player, Config.PROTECTOR_RADIUS_ACTION, false, false)) if (player.isGM() || player.isDead() || !player.isSpawned() || !isInsideRadius(player, Config.PROTECTOR_RADIUS_ACTION, false, false))
{ {
return false; return false;
} }
@@ -96,7 +96,7 @@ public class ProtectorInstance extends NpcInstance
// Cast for pet // Cast for pet
private boolean handleCastonPet(Summon player, int skillId, int skillLevel) private boolean handleCastonPet(Summon player, int skillId, int skillLevel)
{ {
if (player.isDead() || !player.isVisible() || !isInsideRadius(player, Config.PROTECTOR_RADIUS_ACTION, false, false)) if (player.isDead() || !player.isSpawned() || !isInsideRadius(player, Config.PROTECTOR_RADIUS_ACTION, false, false))
{ {
return false; return false;
} }

View File

@@ -366,7 +366,7 @@ public class SepulcherMonsterInstance extends MonsterInstance
return; return;
} }
if (!_activeChar.isVisible()) if (!_activeChar.isSpawned())
{ {
return; return;
} }
@@ -392,7 +392,7 @@ public class SepulcherMonsterInstance extends MonsterInstance
return; return;
} }
if (!_activeChar.isVisible()) if (!_activeChar.isSpawned())
{ {
return; return;
} }

View File

@@ -75,7 +75,7 @@ public class FriendlyMobKnownList extends AttackableKnownList
} }
} }
if (getActiveChar().isVisible() && getKnownPlayers().isEmpty()) if (getActiveChar().isSpawned() && getKnownPlayers().isEmpty())
{ {
getActiveChar().clearAggroList(); getActiveChar().clearAggroList();
if (getActiveChar().hasAI()) if (getActiveChar().hasAI())

View File

@@ -72,7 +72,7 @@ public class MonsterKnownList extends AttackableKnownList
getActiveChar().getAI().notifyEvent(CtrlEvent.EVT_FORGET_OBJECT, object); getActiveChar().getAI().notifyEvent(CtrlEvent.EVT_FORGET_OBJECT, object);
} }
if (getActiveChar().isVisible() && getKnownPlayers().isEmpty()) if (getActiveChar().isSpawned() && getKnownPlayers().isEmpty())
{ {
// Clear the _aggroList of the MonsterInstance // Clear the _aggroList of the MonsterInstance
getActiveChar().clearAggroList(); getActiveChar().clearAggroList();

View File

@@ -51,7 +51,7 @@ public class WorldObjectKnownList
// Check if already know object // Check if already know object
if (knowsObject(object)) if (knowsObject(object))
{ {
if (!object.isVisible()) if (!object.isSpawned())
{ {
removeKnownObject(object); removeKnownObject(object);
} }
@@ -168,7 +168,7 @@ public class WorldObjectKnownList
// Remove all invisible objects // Remove all invisible objects
// Remove all too far objects // Remove all too far objects
if (!object.isVisible() || !Util.checkIfInRange(getDistanceToForgetObject(object), _activeObject, object, true)) if (!object.isSpawned() || !Util.checkIfInRange(getDistanceToForgetObject(object), _activeObject, object, true))
{ {
if ((object instanceof BoatInstance) && (_activeObject instanceof PlayerInstance)) if ((object instanceof BoatInstance) && (_activeObject instanceof PlayerInstance))
{ {

View File

@@ -1090,7 +1090,7 @@ public class ItemInstance extends WorldObject
synchronized (this) synchronized (this)
{ {
// Set the x,y,z position of the ItemInstance dropped and update its _worldregion // Set the x,y,z position of the ItemInstance dropped and update its _worldregion
setVisible(true); setSpawned(true);
getPosition().setWorldPosition(x, y, z); getPosition().setWorldPosition(x, y, z);
getPosition().setWorldRegion(World.getInstance().getRegion(getPosition().getWorldPosition())); getPosition().setWorldRegion(World.getInstance().getRegion(getPosition().getWorldPosition()));

View File

@@ -45,7 +45,7 @@ public class RequestPrivateStoreManageBuy extends GameClientPacket
} }
// Fix for privatestore exploit during login // Fix for privatestore exploit during login
if (!player.isVisible() || player.isLocked()) if (!player.isSpawned() || player.isLocked())
{ {
Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " try exploit at login with privatestore!", Config.DEFAULT_PUNISH); Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " try exploit at login with privatestore!", Config.DEFAULT_PUNISH);
LOGGER.warning("Player " + player.getName() + " try exploit at login with privatestore!"); LOGGER.warning("Player " + player.getName() + " try exploit at login with privatestore!");

View File

@@ -45,7 +45,7 @@ public class RequestPrivateStoreManageSell extends GameClientPacket
} }
// Fix for privatestore exploit during login // Fix for privatestore exploit during login
if (!player.isVisible() || player.isLocked()) if (!player.isSpawned() || player.isLocked())
{ {
Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " try exploit at login with privatestore!", Config.DEFAULT_PUNISH); Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " try exploit at login with privatestore!", Config.DEFAULT_PUNISH);
LOGGER.warning("Player " + player.getName() + " try exploit at login with privatestore!"); LOGGER.warning("Player " + player.getName() + " try exploit at login with privatestore!");

View File

@@ -82,7 +82,7 @@ public class KnownListUpdateTaskManager
{ {
for (WorldObject object : region.getVisibleObjects()) // and for all members in region for (WorldObject object : region.getVisibleObjects()) // and for all members in region
{ {
if (!object.isVisible()) if (!object.isSpawned())
{ {
continue; // skip dying objects continue; // skip dying objects
} }

View File

@@ -152,7 +152,7 @@ abstract class AbstractAI implements Ctrl
@Override @Override
public void setIntention(CtrlIntention intention, Object arg0, Object arg1) public void setIntention(CtrlIntention intention, Object arg0, Object arg1)
{ {
if (!_actor.isVisible() || !_actor.hasAI()) if (!_actor.isSpawned() || !_actor.hasAI())
{ {
return; return;
} }
@@ -252,7 +252,7 @@ abstract class AbstractAI implements Ctrl
@Override @Override
public void notifyEvent(CtrlEvent evt, Object arg0, Object arg1) public void notifyEvent(CtrlEvent evt, Object arg0, Object arg1)
{ {
if (!_actor.isVisible() || !_actor.hasAI() || ((_actor instanceof PlayerInstance) && !((PlayerInstance) _actor).isOnline()) || ((_actor instanceof PlayerInstance) && ((PlayerInstance) _actor).isInOfflineMode())) if (!_actor.isSpawned() || !_actor.hasAI() || ((_actor instanceof PlayerInstance) && !((PlayerInstance) _actor).isOnline()) || ((_actor instanceof PlayerInstance) && ((PlayerInstance) _actor).isInOfflineMode()))
{ {
return; return;
} }

View File

@@ -823,7 +823,7 @@ public class FortSiegeGuardAI extends CreatureAI implements Runnable
@Override @Override
public void onEvtThink() public void onEvtThink()
{ {
// if(getIntention() != AI_INTENTION_IDLE && (!_actor.isVisible() || !_actor.hasAI() || !_actor.isKnownPlayers())) // if(getIntention() != AI_INTENTION_IDLE && (!_actor.isSpawned() || !_actor.hasAI() || !_actor.isKnownPlayers()))
// setIntention(AI_INTENTION_IDLE); // setIntention(AI_INTENTION_IDLE);
// Check if the actor can't use skills and if a thinking action isn't already in progress // Check if the actor can't use skills and if a thinking action isn't already in progress

View File

@@ -69,7 +69,7 @@ public class Resurrect implements ISkillHandler
} }
} }
if (target.isVisible()) if (target.isSpawned())
{ {
targetToRes.add(target); targetToRes.add(target);
} }

View File

@@ -252,7 +252,7 @@ public class DayNightSpawnManager
} }
case 1: case 1:
{ {
if (!boss.isVisible()) if (!boss.isSpawned())
{ {
boss.spawnMe(); boss.spawnMe();
} }

View File

@@ -131,7 +131,7 @@ public class ItemsOnGroundManager
item.getPosition().getWorldRegion().addVisibleObject(item); item.getPosition().getWorldRegion().addVisibleObject(item);
item.setDropTime(result.getLong(8)); item.setDropTime(result.getLong(8));
item.setProtected(result.getLong(8) == -1); item.setProtected(result.getLong(8) == -1);
item.setVisible(true); item.setSpawned(true);
World.getInstance().addVisibleObject(item, item.getPosition().getWorldRegion(), null); World.getInstance().addVisibleObject(item, item.getPosition().getWorldRegion(), null);
_items.add(item); _items.add(item);
count++; count++;

View File

@@ -119,7 +119,7 @@ public class ObjectPosition
} }
setWorldPosition(correctX, correctY, z); setWorldPosition(correctX, correctY, z);
_activeObject.setVisible(false); _activeObject.setSpawned(false);
} }
/** /**
@@ -127,7 +127,7 @@ public class ObjectPosition
*/ */
public void updateWorldRegion() public void updateWorldRegion()
{ {
if (!_activeObject.isVisible()) if (!_activeObject.isSpawned())
{ {
return; return;
} }

View File

@@ -503,7 +503,7 @@ public class World
continue; // skip our own character continue; // skip our own character
} }
if (!wo.isVisible()) if (!wo.isSpawned())
{ {
continue; // skip dying objects continue; // skip dying objects
} }
@@ -533,7 +533,7 @@ public class World
*/ */
public List<WorldObject> getVisibleObjects(WorldObject object, int radius) public List<WorldObject> getVisibleObjects(WorldObject object, int radius)
{ {
if ((object == null) || !object.isVisible()) if ((object == null) || !object.isSpawned())
{ {
return Collections.emptyList(); return Collections.emptyList();
} }
@@ -600,7 +600,7 @@ public class World
*/ */
public List<WorldObject> getVisibleObjects3D(WorldObject object, int radius) public List<WorldObject> getVisibleObjects3D(WorldObject object, int radius)
{ {
if ((object == null) || !object.isVisible()) if ((object == null) || !object.isSpawned())
{ {
return Collections.emptyList(); return Collections.emptyList();
} }
@@ -684,7 +684,7 @@ public class World
continue; // skip our own character continue; // skip our own character
} }
if (!playable.isVisible()) if (!playable.isSpawned())
{ {
continue; // skip dying objects continue; // skip dying objects
} }

View File

@@ -42,7 +42,7 @@ public abstract class WorldObject
{ {
private static final Logger LOGGER = Logger.getLogger(WorldObject.class.getName()); private static final Logger LOGGER = Logger.getLogger(WorldObject.class.getName());
private boolean _visible; private boolean _isSpawned;
private WorldObjectKnownList _knownList; private WorldObjectKnownList _knownList;
private String _name; private String _name;
private int _objectId; private int _objectId;
@@ -134,7 +134,7 @@ public abstract class WorldObject
public void decayMe() public void decayMe()
{ {
// Remove the WorldObject from the world // Remove the WorldObject from the world
_visible = false; _isSpawned = false;
World.getInstance().removeVisibleObject(this, getPosition().getWorldRegion()); World.getInstance().removeVisibleObject(this, getPosition().getWorldRegion());
World.getInstance().removeObject(this); World.getInstance().removeObject(this);
getPosition().setWorldRegion(null); getPosition().setWorldRegion(null);
@@ -170,7 +170,7 @@ public abstract class WorldObject
synchronized (this) synchronized (this)
{ {
_visible = false; _isSpawned = false;
getPosition().setWorldRegion(null); getPosition().setWorldRegion(null);
} }
@@ -218,7 +218,7 @@ public abstract class WorldObject
synchronized (this) synchronized (this)
{ {
// Set the x,y,z position of the WorldObject spawn and update its _worldregion // Set the x,y,z position of the WorldObject spawn and update its _worldregion
_visible = true; _isSpawned = true;
getPosition().setWorldRegion(World.getInstance().getRegion(getPosition().getWorldPosition())); getPosition().setWorldRegion(World.getInstance().getRegion(getPosition().getWorldPosition()));
// Add the WorldObject spawn in the _allobjects of World // Add the WorldObject spawn in the _allobjects of World
@@ -239,7 +239,7 @@ public abstract class WorldObject
synchronized (this) synchronized (this)
{ {
// Set the x,y,z position of the WorldObject spawn and update its _worldregion // Set the x,y,z position of the WorldObject spawn and update its _worldregion
_visible = true; _isSpawned = true;
int spawnX = x; int spawnX = x;
if (spawnX > World.MAP_MAX_X) if (spawnX > World.MAP_MAX_X)
@@ -288,7 +288,7 @@ public abstract class WorldObject
public void toggleVisible() public void toggleVisible()
{ {
if (isVisible()) if (isSpawned())
{ {
decayMe(); decayMe();
} }
@@ -300,21 +300,15 @@ public abstract class WorldObject
public abstract boolean isAutoAttackable(Creature attacker); public abstract boolean isAutoAttackable(Creature attacker);
/** public boolean isSpawned()
* <b><u>Concept</u>:</b><br>
* <br>
* A WorldObject is visible if <b>__IsVisible</b>=true and <b>_worldregion</b>!=null
* @return the visibility state of the WorldObject.
*/
public boolean isVisible()
{ {
return getPosition().getWorldRegion() != null; return getPosition().getWorldRegion() != null;
} }
public void setVisible(boolean value) public void setSpawned(boolean value)
{ {
_visible = value; _isSpawned = value;
if (!_visible) if (!_isSpawned)
{ {
getPosition().setWorldRegion(null); getPosition().setWorldRegion(null);
} }
@@ -387,7 +381,7 @@ public abstract class WorldObject
_instanceId = instanceId; _instanceId = instanceId;
// If we change it for visible objects, me must clear & revalidates knownlists // If we change it for visible objects, me must clear & revalidates knownlists
if (_visible && (_knownList != null)) if (_isSpawned && (_knownList != null))
{ {
if (this instanceof PlayerInstance) if (this instanceof PlayerInstance)
{ {

View File

@@ -1105,7 +1105,7 @@ public class Attackable extends NpcInstance
continue; continue;
} }
if (ai._attacker.isAlikeDead() || !getKnownList().knowsObject(ai._attacker) || !ai._attacker.isVisible() || ((ai._attacker instanceof PlayerInstance) && !((PlayerInstance) ai._attacker).isOnline() && !((PlayerInstance) ai._attacker).isInOfflineMode())) if (ai._attacker.isAlikeDead() || !getKnownList().knowsObject(ai._attacker) || !ai._attacker.isSpawned() || ((ai._attacker instanceof PlayerInstance) && !((PlayerInstance) ai._attacker).isOnline() && !((PlayerInstance) ai._attacker).isInOfflineMode()))
{ {
ai._hate = 0; ai._hate = 0;
} }
@@ -1156,7 +1156,7 @@ public class Attackable extends NpcInstance
return 0; return 0;
} }
if (!ai._attacker.isVisible()) if (!ai._attacker.isSpawned())
{ {
_aggroList.remove(target); _aggroList.remove(target);
return 0; return 0;

View File

@@ -5193,7 +5193,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
return true; return true;
} }
if (!isVisible()) if (!isSpawned())
{ {
_move = null; _move = null;
return true; return true;
@@ -5409,7 +5409,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
public void setTarget(WorldObject worldObject) public void setTarget(WorldObject worldObject)
{ {
WorldObject object = worldObject; WorldObject object = worldObject;
if ((object != null) && !object.isVisible()) if ((object != null) && !object.isSpawned())
{ {
object = null; object = null;
} }

View File

@@ -384,7 +384,7 @@ public abstract class Summon extends Playable
{ {
super.broadcastStatusUpdate(); super.broadcastStatusUpdate();
if ((_owner != null) && isVisible()) if ((_owner != null) && isSpawned())
{ {
_owner.sendPacket(new PetStatusUpdate(this)); _owner.sendPacket(new PetStatusUpdate(this));
} }
@@ -404,7 +404,7 @@ public abstract class Summon extends Playable
public synchronized void unSummon(PlayerInstance owner) public synchronized void unSummon(PlayerInstance owner)
{ {
if (isVisible() && !isDead()) if (isSpawned() && !isDead())
{ {
stopAllEffects(); stopAllEffects();

View File

@@ -153,7 +153,7 @@ public class CabaleBufferInstance extends NpcInstance
private boolean handleCast(PlayerInstance player, int skillId) private boolean handleCast(PlayerInstance player, int skillId)
{ {
final int skillLevel = player.getLevel() > 40 ? 1 : 2; final int skillLevel = player.getLevel() > 40 ? 1 : 2;
if (player.isDead() || !player.isVisible() || !isInsideRadius(player, getDistanceToWatchObject(player), false, false)) if (player.isDead() || !player.isSpawned() || !isInsideRadius(player, getDistanceToWatchObject(player), false, false))
{ {
return false; return false;
} }

View File

@@ -204,7 +204,7 @@ public class ChestInstance extends MonsterInstance
skillLevel = 6; skillLevel = 6;
} }
if (creature.isDead() || !creature.isVisible() || !creature.isInsideRadius(this, getDistanceToWatchObject(creature), false, false)) if (creature.isDead() || !creature.isSpawned() || !creature.isInsideRadius(this, getDistanceToWatchObject(creature), false, false))
{ {
return false; return false;
} }

View File

@@ -524,7 +524,7 @@ public class CubicInstance
{ {
targetIt = false; targetIt = false;
} }
if (!enemy.isVisible()) if (!enemy.isSpawned())
{ {
targetIt = false; targetIt = false;
} }

View File

@@ -485,7 +485,7 @@ public class PetInstance extends Summon
synchronized (target) synchronized (target)
{ {
if (!target.isVisible()) if (!target.isSpawned())
{ {
getOwner().sendPacket(ActionFailed.STATIC_PACKET); getOwner().sendPacket(ActionFailed.STATIC_PACKET);
return; return;

View File

@@ -5192,7 +5192,7 @@ public class PlayerInstance extends Playable
synchronized (target) synchronized (target)
{ {
// Check if the target to pick up is visible // Check if the target to pick up is visible
if (!target.isVisible()) if (!target.isSpawned())
{ {
// Send a Server->Client packet ActionFailed to this PlayerInstance // Send a Server->Client packet ActionFailed to this PlayerInstance
sendPacket(ActionFailed.STATIC_PACKET); sendPacket(ActionFailed.STATIC_PACKET);
@@ -5364,7 +5364,7 @@ public class PlayerInstance extends Playable
{ {
// Check if the new target is visible // Check if the new target is visible
WorldObject newTarget = worldObject; WorldObject newTarget = worldObject;
if ((newTarget != null) && !newTarget.isVisible()) if ((newTarget != null) && !newTarget.isSpawned())
{ {
newTarget = null; newTarget = null;
} }
@@ -13039,7 +13039,7 @@ public class PlayerInstance extends Playable
return true; return true;
} }
if (!isVisible()) if (!isSpawned())
{ {
_move = null; _move = null;
return true; return true;
@@ -13829,7 +13829,7 @@ public class PlayerInstance extends Playable
} }
// Remove the PlayerInstance from the world // Remove the PlayerInstance from the world
if (isVisible()) if (isSpawned())
{ {
try try
{ {

View File

@@ -75,7 +75,7 @@ public class ProtectorInstance extends NpcInstance
// Cast for Player // Cast for Player
private boolean handleCast(PlayerInstance player, int skillId, int skillLevel) private boolean handleCast(PlayerInstance player, int skillId, int skillLevel)
{ {
if (player.isGM() || player.isDead() || !player.isVisible() || !isInsideRadius(player, Config.PROTECTOR_RADIUS_ACTION, false, false)) if (player.isGM() || player.isDead() || !player.isSpawned() || !isInsideRadius(player, Config.PROTECTOR_RADIUS_ACTION, false, false))
{ {
return false; return false;
} }
@@ -96,7 +96,7 @@ public class ProtectorInstance extends NpcInstance
// Cast for pet // Cast for pet
private boolean handleCastonPet(Summon player, int skillId, int skillLevel) private boolean handleCastonPet(Summon player, int skillId, int skillLevel)
{ {
if (player.isDead() || !player.isVisible() || !isInsideRadius(player, Config.PROTECTOR_RADIUS_ACTION, false, false)) if (player.isDead() || !player.isSpawned() || !isInsideRadius(player, Config.PROTECTOR_RADIUS_ACTION, false, false))
{ {
return false; return false;
} }

View File

@@ -366,7 +366,7 @@ public class SepulcherMonsterInstance extends MonsterInstance
return; return;
} }
if (!_activeChar.isVisible()) if (!_activeChar.isSpawned())
{ {
return; return;
} }
@@ -392,7 +392,7 @@ public class SepulcherMonsterInstance extends MonsterInstance
return; return;
} }
if (!_activeChar.isVisible()) if (!_activeChar.isSpawned())
{ {
return; return;
} }

View File

@@ -75,7 +75,7 @@ public class FriendlyMobKnownList extends AttackableKnownList
} }
} }
if (getActiveChar().isVisible() && getKnownPlayers().isEmpty()) if (getActiveChar().isSpawned() && getKnownPlayers().isEmpty())
{ {
getActiveChar().clearAggroList(); getActiveChar().clearAggroList();
if (getActiveChar().hasAI()) if (getActiveChar().hasAI())

View File

@@ -72,7 +72,7 @@ public class MonsterKnownList extends AttackableKnownList
getActiveChar().getAI().notifyEvent(CtrlEvent.EVT_FORGET_OBJECT, object); getActiveChar().getAI().notifyEvent(CtrlEvent.EVT_FORGET_OBJECT, object);
} }
if (getActiveChar().isVisible() && getKnownPlayers().isEmpty()) if (getActiveChar().isSpawned() && getKnownPlayers().isEmpty())
{ {
// Clear the _aggroList of the MonsterInstance // Clear the _aggroList of the MonsterInstance
getActiveChar().clearAggroList(); getActiveChar().clearAggroList();

View File

@@ -51,7 +51,7 @@ public class WorldObjectKnownList
// Check if already know object // Check if already know object
if (knowsObject(object)) if (knowsObject(object))
{ {
if (!object.isVisible()) if (!object.isSpawned())
{ {
removeKnownObject(object); removeKnownObject(object);
} }
@@ -168,7 +168,7 @@ public class WorldObjectKnownList
// Remove all invisible objects // Remove all invisible objects
// Remove all too far objects // Remove all too far objects
if (!object.isVisible() || !Util.checkIfInRange(getDistanceToForgetObject(object), _activeObject, object, true)) if (!object.isSpawned() || !Util.checkIfInRange(getDistanceToForgetObject(object), _activeObject, object, true))
{ {
if ((object instanceof BoatInstance) && (_activeObject instanceof PlayerInstance)) if ((object instanceof BoatInstance) && (_activeObject instanceof PlayerInstance))
{ {

View File

@@ -1151,7 +1151,7 @@ public class ItemInstance extends WorldObject
synchronized (this) synchronized (this)
{ {
// Set the x,y,z position of the ItemInstance dropped and update its _worldregion // Set the x,y,z position of the ItemInstance dropped and update its _worldregion
setVisible(true); setSpawned(true);
getPosition().setWorldPosition(x, y, z); getPosition().setWorldPosition(x, y, z);
getPosition().setWorldRegion(World.getInstance().getRegion(getPosition().getWorldPosition())); getPosition().setWorldRegion(World.getInstance().getRegion(getPosition().getWorldPosition()));

View File

@@ -45,7 +45,7 @@ public class RequestPrivateStoreManageBuy extends GameClientPacket
} }
// Fix for privatestore exploit during login // Fix for privatestore exploit during login
if (!player.isVisible() || player.isLocked()) if (!player.isSpawned() || player.isLocked())
{ {
Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " try exploit at login with privatestore!", Config.DEFAULT_PUNISH); Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " try exploit at login with privatestore!", Config.DEFAULT_PUNISH);
LOGGER.warning("Player " + player.getName() + " try exploit at login with privatestore!"); LOGGER.warning("Player " + player.getName() + " try exploit at login with privatestore!");

View File

@@ -45,7 +45,7 @@ public class RequestPrivateStoreManageSell extends GameClientPacket
} }
// Fix for privatestore exploit during login // Fix for privatestore exploit during login
if (!player.isVisible() || player.isLocked()) if (!player.isSpawned() || player.isLocked())
{ {
Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " try exploit at login with privatestore!", Config.DEFAULT_PUNISH); Util.handleIllegalPlayerAction(player, "Player " + player.getName() + " try exploit at login with privatestore!", Config.DEFAULT_PUNISH);
LOGGER.warning("Player " + player.getName() + " try exploit at login with privatestore!"); LOGGER.warning("Player " + player.getName() + " try exploit at login with privatestore!");

View File

@@ -82,7 +82,7 @@ public class KnownListUpdateTaskManager
{ {
for (WorldObject object : region.getVisibleObjects()) // and for all members in region for (WorldObject object : region.getVisibleObjects()) // and for all members in region
{ {
if (!object.isVisible()) if (!object.isSpawned())
{ {
continue; // skip dying objects continue; // skip dying objects
} }

View File

@@ -635,7 +635,7 @@ public class FortSiegeGuardAI extends CreatureAI implements Runnable
@Override @Override
public void onEvtThink() public void onEvtThink()
{ {
// if(getIntention() != AI_INTENTION_IDLE && (!_actor.isVisible() || !_actor.hasAI() || !_actor.isKnownPlayers())) // if(getIntention() != AI_INTENTION_IDLE && (!_actor.isSpawned() || !_actor.hasAI() || !_actor.isKnownPlayers()))
// setIntention(AI_INTENTION_IDLE); // setIntention(AI_INTENTION_IDLE);
// Check if the actor can't use skills and if a thinking action isn't already in progress // Check if the actor can't use skills and if a thinking action isn't already in progress

View File

@@ -636,7 +636,7 @@ public class SiegeGuardAI extends CreatureAI implements Runnable
@Override @Override
public void onEvtThink() public void onEvtThink()
{ {
// if(getIntention() != AI_INTENTION_IDLE && (!_actor.isVisible() || !_actor.hasAI() || !_actor.isKnownPlayers())) // if(getIntention() != AI_INTENTION_IDLE && (!_actor.isSpawned() || !_actor.hasAI() || !_actor.isKnownPlayers()))
// setIntention(AI_INTENTION_IDLE); // setIntention(AI_INTENTION_IDLE);
// Check if the thinking action is already in progress // Check if the thinking action is already in progress

View File

@@ -635,7 +635,7 @@ public class FortSiegeGuardAI extends CreatureAI implements Runnable
@Override @Override
public void onEvtThink() public void onEvtThink()
{ {
// if(getIntention() != AI_INTENTION_IDLE && (!_actor.isVisible() || !_actor.hasAI() || !_actor.isKnownPlayers())) // if(getIntention() != AI_INTENTION_IDLE && (!_actor.isSpawned() || !_actor.hasAI() || !_actor.isKnownPlayers()))
// setIntention(AI_INTENTION_IDLE); // setIntention(AI_INTENTION_IDLE);
// Check if the actor can't use skills and if a thinking action isn't already in progress // Check if the actor can't use skills and if a thinking action isn't already in progress

View File

@@ -636,7 +636,7 @@ public class SiegeGuardAI extends CreatureAI implements Runnable
@Override @Override
public void onEvtThink() public void onEvtThink()
{ {
// if(getIntention() != AI_INTENTION_IDLE && (!_actor.isVisible() || !_actor.hasAI() || !_actor.isKnownPlayers())) // if(getIntention() != AI_INTENTION_IDLE && (!_actor.isSpawned() || !_actor.hasAI() || !_actor.isKnownPlayers()))
// setIntention(AI_INTENTION_IDLE); // setIntention(AI_INTENTION_IDLE);
// Check if the thinking action is already in progress // Check if the thinking action is already in progress