support the case where the main mission from the mission giver is not the first in the list of affected factions
This commit is contained in:
@@ -12,9 +12,16 @@ namespace EliteBGS.BGS {
|
||||
|
||||
public override string ToString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
string missionname;
|
||||
|
||||
if (RelevantMission != null) {
|
||||
missionname = RelevantMission.MissionName;
|
||||
} else {
|
||||
missionname = "UNKNOWN MISSION";
|
||||
}
|
||||
|
||||
builder.AppendFormat("Influence gained from \"{0}\": \"{1}\"",
|
||||
RelevantMission.MissionName,
|
||||
missionname,
|
||||
string.IsNullOrEmpty(Influence) ? "NONE" : Influence
|
||||
);
|
||||
|
||||
|
||||
@@ -183,7 +183,8 @@ namespace EliteBGS.BGS {
|
||||
collate = true;
|
||||
} else if (e.Is(Events.MissionCompleted)) {
|
||||
MissionCompletedEntry completed = e as MissionCompletedEntry;
|
||||
MissionAcceptedEntry accepted;
|
||||
MissionAcceptedEntry accepted = null;
|
||||
MissionCompleted main_mission = null;
|
||||
|
||||
if (!acceptedMissions.TryGetValue(completed.MissionID, out accepted)) {
|
||||
OnLog?.Invoke(string.Format(
|
||||
@@ -245,14 +246,27 @@ namespace EliteBGS.BGS {
|
||||
if (faction.Equals(mission_giver) && system_address == accepted_address) {
|
||||
/* This is the influence block for the origin of the mission.
|
||||
*/
|
||||
results.Add(new MissionCompleted(completed) {
|
||||
main_mission = new MissionCompleted(completed) {
|
||||
System = accepted_system,
|
||||
Faction = mission_giver,
|
||||
SystemAddress = accepted_address,
|
||||
Station = accepted_station,
|
||||
});
|
||||
} else if (!faction.Equals(results[0].Faction) ||
|
||||
(faction.Equals(results[0].Faction) && system_address != accepted_address)) {
|
||||
};
|
||||
/* We might already have secondary missions, so update them.
|
||||
* We cannot rely on the order in which they are listed in the affected
|
||||
* factions.
|
||||
*/
|
||||
if (results.Count() > 0) {
|
||||
results
|
||||
.ForEach(x => {
|
||||
if (x.GetType() == typeof(InfluenceSupport)) {
|
||||
(x as InfluenceSupport).RelevantMission = main_mission;
|
||||
}
|
||||
});
|
||||
}
|
||||
results.Add(main_mission);
|
||||
} else if (!faction.Equals(mission_giver) ||
|
||||
(faction.Equals(mission_giver) && system_address != accepted_address)) {
|
||||
/* This block is for secondary factions (first if), or if the secondary faction
|
||||
* is the same as the mission giver, but in another system (second if).
|
||||
*/
|
||||
@@ -261,7 +275,8 @@ namespace EliteBGS.BGS {
|
||||
Influence = influences.Value,
|
||||
System = system,
|
||||
SystemAddress = system_address,
|
||||
RelevantMission = results[0] as MissionCompleted
|
||||
/* main mission might be null, and may be fixed later */
|
||||
RelevantMission = main_mission
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user