Skip to content

Commit

Permalink
Workaround for stock bug where extra messages get deployed (#18267).
Browse files Browse the repository at this point in the history
  • Loading branch information
jrossignol committed Apr 2, 2018
1 parent 954f417 commit c681268
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Contract Configurator 1.24.2
- Workaround for stock bug #18267 (contract parameters creating extra messages on completion).

Contract Configurator 1.24.1
- Recompile against KSP 1.4.2
- Re-enabled RemoteTech and Kerbal Konstructs integration for KSP 1.4.x.
Expand Down
Binary file modified GameData/ContractConfigurator/ContractConfigurator.dll
Binary file not shown.
Binary file modified GameData/ContractConfigurator/KerKonConConExt.dll
Binary file not shown.
19 changes: 19 additions & 0 deletions source/ContractConfigurator/ContractConfigurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ void Start()

OnParameterChange.Add(new EventData<Contract, ContractParameter>.OnEvent(ParameterChange));
GameEvents.OnTechnologyResearched.Add(new EventData<GameEvents.HostTargetAction<RDTech, RDTech.OperationResult>>.OnEvent(OnTechResearched));
GameEvents.Contract.onParameterChange.Add(new EventData<Contract, ContractParameter>.OnEvent(StockOnParameterChange));
}

void Destroy()
{
OnParameterChange.Remove(new EventData<Contract, ContractParameter>.OnEvent(ParameterChange));
GameEvents.OnTechnologyResearched.Remove(new EventData<GameEvents.HostTargetAction<RDTech, RDTech.OperationResult>>.OnEvent(OnTechResearched));
GameEvents.Contract.onParameterChange.Remove(new EventData<Contract, ContractParameter>.OnEvent(StockOnParameterChange));
}

void PSystemReady()
Expand Down Expand Up @@ -128,6 +130,23 @@ private void ParameterChange(Contract c, ContractParameter p)
GameEvents.Contract.onParameterChange.Fire(c, p);
}

void StockOnParameterChange(Contract c, ContractParameter p)
{
// Workaround for stock bug #18267
if (p.State == ParameterState.Complete && (p.FundsCompletion != 0 || p.ScienceCompletion != 0 || p.ReputationCompletion != 0))
{
Versioning v = Versioning.Instance as Versioning;
if (v.versionMinor == 1 && v.versionMinor == 4 && v.revision == 2)
{
MessageSystem.Message message = MessageSystem.Instance.FindMessages(m => m.message.Contains(p.MessageComplete)).FirstOrDefault();
if (message != null)
{
MessageSystem.Instance.DiscardMessage(message.button);
}
}
}
}

public void OnGUI()
{
DebugWindow.OnGUI();
Expand Down

0 comments on commit c681268

Please sign in to comment.