Skip to content

Commit

Permalink
DirectEve.ActiveShip.Entity now returns null when no entity has been …
Browse files Browse the repository at this point in the history
…found

Questor has been fixed to properly handle this.
  • Loading branch information
Da-Teach committed Mar 22, 2011
1 parent 2fed920 commit 16b7935
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 7 deletions.
Binary file modified DirectEve/DirectEve.dll
Binary file not shown.
7 changes: 5 additions & 2 deletions Questor.Modules/Cache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ public bool InStation

public bool InWarp
{
get { return DirectEve.ActiveShip.Entity.Mode == 3; }
get { return DirectEve.ActiveShip.Entity != null ? DirectEve.ActiveShip.Entity.Mode == 3 : false; }
}

public IEnumerable<EntityCache> ActiveDrones
Expand Down Expand Up @@ -377,7 +377,7 @@ public EntityCache Approaching
if (_approaching == null)
{
var ship = DirectEve.ActiveShip.Entity;
if (ship.IsValid)
if (ship != null && ship.IsValid)
_approaching = EntityById(ship.FollowId);
}

Expand Down Expand Up @@ -671,6 +671,9 @@ public void AddPriorityTargets(IEnumerable<EntityCache> targets, Priority priori
/// <returns></returns>
public double DistanceFromMe(double x, double y, double z)
{
if (DirectEve.ActiveShip.Entity == null)
return 0;

var curX = DirectEve.ActiveShip.Entity.X;
var curY = DirectEve.ActiveShip.Entity.Y;
var curZ = DirectEve.ActiveShip.Entity.Z;
Expand Down
4 changes: 4 additions & 0 deletions Questor.Modules/Combat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,10 @@ public void ProcessState()
if (Cache.Instance.InStation)
return;

// What? No ship entity?
if (Cache.Instance.DirectEve.ActiveShip.Entity == null)
return;

// There is no combat when cloaked
if (Cache.Instance.DirectEve.ActiveShip.Entity.IsCloaked)
return;
Expand Down
4 changes: 4 additions & 0 deletions Questor.Modules/Defense.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ public void ProcessState()
if (Cache.Instance.InStation)
return;

// What? No ship entity?
if (Cache.Instance.DirectEve.ActiveShip.Entity == null)
return;

// There is no better defense then being cloaked ;)
if (Cache.Instance.DirectEve.ActiveShip.Entity.IsCloaked)
return;
Expand Down
7 changes: 5 additions & 2 deletions Questor.Modules/EntityCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,11 @@ public bool HaveLootRights
if (_directEntity != null)
{
var haveLootRights = false;
haveLootRights |= _directEntity.CorpId == Cache.Instance.DirectEve.ActiveShip.Entity.CorpId;
haveLootRights |= _directEntity.OwnerId == Cache.Instance.DirectEve.ActiveShip.Entity.CharId;
if (Cache.Instance.DirectEve.ActiveShip.Entity != null)
{
haveLootRights |= _directEntity.CorpId == Cache.Instance.DirectEve.ActiveShip.Entity.CorpId;
haveLootRights |= _directEntity.OwnerId == Cache.Instance.DirectEve.ActiveShip.Entity.CharId;
}

return haveLootRights;
}
Expand Down
4 changes: 4 additions & 0 deletions Questor.Modules/MissionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,10 @@ private void PerformAction(Action action)

public void ProcessState()
{
// What? No ship entity?
if (Cache.Instance.DirectEve.ActiveShip.Entity == null)
return;

switch (State)
{
case MissionControllerState.Idle:
Expand Down
9 changes: 6 additions & 3 deletions Questor.Modules/Panic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ public void ProcessState()
switch (State)
{
case PanicState.Normal:
_lastNormalX = Cache.Instance.DirectEve.ActiveShip.Entity.X;
_lastNormalY = Cache.Instance.DirectEve.ActiveShip.Entity.Y;
_lastNormalZ = Cache.Instance.DirectEve.ActiveShip.Entity.Z;
if (Cache.Instance.DirectEve.ActiveShip.Entity != null)
{
_lastNormalX = Cache.Instance.DirectEve.ActiveShip.Entity.X;
_lastNormalY = Cache.Instance.DirectEve.ActiveShip.Entity.Y;
_lastNormalZ = Cache.Instance.DirectEve.ActiveShip.Entity.Z;
}

if (Cache.Instance.DirectEve.ActiveShip.GroupId == (int) Group.Capsule)
{
Expand Down

0 comments on commit 16b7935

Please sign in to comment.