Skip to content

Commit

Permalink
issue with storylines in lowsec being 'declined' (unsuccessfully) and…
Browse files Browse the repository at this point in the history
… hanging questor in a loop should now be fixed. please test.
  • Loading branch information
ISeeDEDPpl committed May 28, 2012
1 parent c553d6d commit 95c9fce
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 25 deletions.
11 changes: 10 additions & 1 deletion Questor.Modules/Actions/AgentInteraction.cs
Expand Up @@ -567,10 +567,19 @@ private void DeclineMission()
_States.CurrentAgentInteractionState = AgentInteractionState.ChangeAgent;
return;
}

Logging.Log("AgentInteraction", "Current standings [" + Cache.Instance.AgentEffectiveStandingtoMe + "] is above or configured minimum [" + Settings.Instance.MinAgentBlackListStandings + "]. Declining [" + Cache.Instance.MissionName + "]", Logging.yellow);
}
}
if (_States.CurrentStorylineState == StorylineState.AcceptMission)
{
Logging.Log("AgentInteraction", "Storyline: Storylines cannot be declined, thus we will add this agent to the blacklist for this session.", Logging.yellow);
_States.CurrentStorylineState = StorylineState.Idle;
_States.CurrentCombatMissionBehaviorState = CombatMissionsBehaviorState.GotoBase;
_States.CurrentAgentInteractionState = AgentInteractionState.Idle;
Cache.Instance.AgentBlacklist.Add(Cache.Instance.CurrentStorylineAgentId);
return;
}


// Decline and request a new mission
Logging.Log("AgentInteraction", "Saying [Decline]", Logging.yellow);
Expand Down
11 changes: 11 additions & 0 deletions Questor.Modules/Caching/Cache.cs
Expand Up @@ -47,6 +47,17 @@ public class Cache
/// </summary>
private long? _agentId;

/// <summary>
/// Current Storyline Mission Agent
/// </summary>
public long CurrentStorylineAgentId { get; set; }

/// <summary>
/// Agent blacklist
/// </summary>
public List<long> AgentBlacklist;


/// <summary>
/// Approaching cache
/// </summary>
Expand Down
10 changes: 5 additions & 5 deletions Questor/Storylines/GenericCombatStoryline.cs
Expand Up @@ -74,10 +74,10 @@ private void ApplySettings(object sender, EventArgs e)
/// <returns></returns>
public StorylineState Arm(Storyline storyline)
{
if (_agentId != storyline.CurrentStorylineAgentId)
if (_agentId != Cache.Instance.CurrentStorylineAgentId)
{
_neededAmmo.Clear();
_agentId = storyline.CurrentStorylineAgentId;
_agentId = Cache.Instance.CurrentStorylineAgentId;

_agentInteraction.AgentId = _agentId;
_agentInteraction.ForceAccept = true; // This makes agent interaction skip the offer-check
Expand Down Expand Up @@ -251,11 +251,11 @@ public StorylineState ExecuteMission(Storyline storyline)
//
//if (missionDestination != null) Logging.Log("GenericCombatStoryline: missionDestination.AgentId [" + missionDestination.AgentId + "] " + "and storyline.CurrentStorylineAgentId [" + storyline.CurrentStorylineAgentId + "]");
//if (missionDestination == null) Logging.Log("GenericCombatStoryline: missionDestination.AgentId [ NULL ] " + "and storyline.CurrentStorylineAgentId [" + storyline.CurrentStorylineAgentId + "]");
if (missionDestination == null || missionDestination.AgentId != storyline.CurrentStorylineAgentId) // We assume that this will always work "correctly" (tm)
if (missionDestination == null || missionDestination.AgentId != Cache.Instance.CurrentStorylineAgentId) // We assume that this will always work "correctly" (tm)
{
const string nameOfBookmark = "Encounter";
Logging.Log("GenericCombatStoryline", "Setting Destination to 1st bookmark from AgentID: [" + storyline.CurrentStorylineAgentId + "] with [" + nameOfBookmark + "] in the title", Logging.white);
_traveler.Destination = new MissionBookmarkDestination(Cache.Instance.GetMissionBookmark(storyline.CurrentStorylineAgentId, nameOfBookmark));
Logging.Log("GenericCombatStoryline", "Setting Destination to 1st bookmark from AgentID: [" + Cache.Instance.CurrentStorylineAgentId + "] with [" + nameOfBookmark + "] in the title", Logging.white);
_traveler.Destination = new MissionBookmarkDestination(Cache.Instance.GetMissionBookmark(Cache.Instance.CurrentStorylineAgentId, nameOfBookmark));
}

if (Cache.Instance.PriorityTargets.Any(pt => pt != null && pt.IsValid))
Expand Down
4 changes: 2 additions & 2 deletions Questor/Storylines/GenericCourierStoryline.cs
Expand Up @@ -171,7 +171,7 @@ public StorylineState ExecuteMission(Storyline storyline)
switch (_state)
{
case GenericCourierStorylineState.GotoPickupLocation:
if (GotoMissionBookmark(storyline.CurrentStorylineAgentId, "Objective (Pick Up)"))
if (GotoMissionBookmark(Cache.Instance.CurrentStorylineAgentId, "Objective (Pick Up)"))
_state = GenericCourierStorylineState.PickupItem;
break;

Expand All @@ -181,7 +181,7 @@ public StorylineState ExecuteMission(Storyline storyline)
break;

case GenericCourierStorylineState.GotoDropOffLocation:
if (GotoMissionBookmark(storyline.CurrentStorylineAgentId, "Objective (Drop Off)"))
if (GotoMissionBookmark(Cache.Instance.CurrentStorylineAgentId, "Objective (Drop Off)"))
_state = GenericCourierStorylineState.DropOffItem;
break;

Expand Down
28 changes: 13 additions & 15 deletions Questor/Storylines/Storyline.cs
Expand Up @@ -15,11 +15,9 @@ namespace Questor.Storylines

public class Storyline
{
public long CurrentStorylineAgentId { get; private set; }

private IStoryline _storyline;
private readonly Dictionary<string, IStoryline> _storylines;
private readonly List<long> _agentBlacklist;
//public List<long> AgentBlacklist;

private readonly Combat _combat;
private readonly Traveler _traveler;
Expand All @@ -34,7 +32,7 @@ public Storyline()
_traveler = new Traveler();
_agentInteraction = new AgentInteraction();

_agentBlacklist = new List<long>();
Cache.Instance.AgentBlacklist = new List<long>();

_storylines = new Dictionary<string, IStoryline>
{
Expand Down Expand Up @@ -77,7 +75,7 @@ public Storyline()
public void Reset()
{
_States.CurrentStorylineState = StorylineState.Idle;
CurrentStorylineAgentId = 0;
Cache.Instance.CurrentStorylineAgentId = 0;
_storyline = null;
_States.CurrentAgentInteractionState = AgentInteractionState.Idle;
_States.CurrentTravelerState = TravelerState.Idle;
Expand All @@ -89,10 +87,10 @@ private DirectAgentMission StorylineMission
get
{
IEnumerable<DirectAgentMission> missionsinjournal = Cache.Instance.DirectEve.AgentMissions;
if (CurrentStorylineAgentId != 0)
return missionsinjournal.FirstOrDefault(m => m.AgentId == CurrentStorylineAgentId);
if (Cache.Instance.CurrentStorylineAgentId != 0)
return missionsinjournal.FirstOrDefault(m => m.AgentId == Cache.Instance.CurrentStorylineAgentId);

missionsinjournal = missionsinjournal.Where(m => !_agentBlacklist.Contains(m.AgentId));
missionsinjournal = missionsinjournal.Where(m => !Cache.Instance.AgentBlacklist.Contains(m.AgentId));
missionsinjournal = missionsinjournal.Where(m => m.Important);
missionsinjournal = missionsinjournal.Where(m => _storylines.ContainsKey(Cache.Instance.FilterPath(m.Name)));
missionsinjournal = missionsinjournal.Where(m => !Settings.Instance.MissionBlacklist.Any(b => b.ToLower() == Cache.Instance.FilterPath(m.Name).ToLower()));
Expand All @@ -112,17 +110,17 @@ private void IdleState()
return;
}

CurrentStorylineAgentId = currentStorylineMission.AgentId;
DirectAgent storylineagent = Cache.Instance.DirectEve.GetAgentById(CurrentStorylineAgentId);
Cache.Instance.CurrentStorylineAgentId = currentStorylineMission.AgentId;
DirectAgent storylineagent = Cache.Instance.DirectEve.GetAgentById(Cache.Instance.CurrentStorylineAgentId);
if (storylineagent == null)
{
Logging.Log("Storyline", "Unknown agent [" + CurrentStorylineAgentId + "]", Logging.yellow);
Logging.Log("Storyline", "Unknown agent [" + Cache.Instance.CurrentStorylineAgentId + "]", Logging.yellow);

_States.CurrentStorylineState = StorylineState.Done;
return;
}

Logging.Log("Storyline", "Going to do [" + currentStorylineMission.Name + "] for agent [" + storylineagent.Name + "] AgentID[" + CurrentStorylineAgentId + "]", Logging.yellow);
Logging.Log("Storyline", "Going to do [" + currentStorylineMission.Name + "] for agent [" + storylineagent.Name + "] AgentID[" + Cache.Instance.CurrentStorylineAgentId + "]", Logging.yellow);
Cache.Instance.MissionName = currentStorylineMission.Name;

_States.CurrentStorylineState = StorylineState.Arm;
Expand All @@ -131,7 +129,7 @@ private void IdleState()

private void GotoAgent(StorylineState nextState)
{
DirectAgent storylineagent = Cache.Instance.DirectEve.GetAgentById(CurrentStorylineAgentId);
DirectAgent storylineagent = Cache.Instance.DirectEve.GetAgentById(Cache.Instance.CurrentStorylineAgentId);
if (storylineagent == null)
{
_States.CurrentStorylineState = StorylineState.Done;
Expand Down Expand Up @@ -230,7 +228,7 @@ public void ProcessState()

_States.CurrentAgentInteractionState = AgentInteractionState.StartConversation;
_agentInteraction.Purpose = AgentInteractionPurpose.StartMission;
_agentInteraction.AgentId = CurrentStorylineAgentId;
_agentInteraction.AgentId = Cache.Instance.CurrentStorylineAgentId;
_agentInteraction.ForceAccept = true;
}

Expand Down Expand Up @@ -281,7 +279,7 @@ public void ProcessState()
break;

case StorylineState.BlacklistAgent:
_agentBlacklist.Add(CurrentStorylineAgentId);
Cache.Instance.AgentBlacklist.Add(Cache.Instance.CurrentStorylineAgentId);
_States.CurrentStorylineState = StorylineState.Done;
break;

Expand Down
4 changes: 2 additions & 2 deletions Questor/Storylines/TransactionDataDelivery.cs
Expand Up @@ -137,7 +137,7 @@ public StorylineState ExecuteMission(Storyline storyline)
switch (_state)
{
case TransactionDataDeliveryState.GotoPickupLocation:
if (GotoMissionBookmark(storyline.CurrentStorylineAgentId, "Objective (Pick Up)"))
if (GotoMissionBookmark(Cache.Instance.CurrentStorylineAgentId, "Objective (Pick Up)"))
_state = TransactionDataDeliveryState.PickupItem;
break;

Expand All @@ -147,7 +147,7 @@ public StorylineState ExecuteMission(Storyline storyline)
break;

case TransactionDataDeliveryState.GotoDropOffLocation:
if (GotoMissionBookmark(storyline.CurrentStorylineAgentId, "Objective (Drop Off)"))
if (GotoMissionBookmark(Cache.Instance.CurrentStorylineAgentId, "Objective (Drop Off)"))
_state = TransactionDataDeliveryState.DropOffItem;
break;

Expand Down

0 comments on commit 95c9fce

Please sign in to comment.