tomforwood / kerbal-impact

MIT License
8 stars 4 forks source link

IScienceDataContainer implementations, Seismometer and Spectrometer, return bad results for GetData() if their result is null #2

Closed xEvilReeperx closed 9 years ago

xEvilReeperx commented 9 years ago

Hi, there looks to be a small bug in how you handle IScienceDataContainer.GetData in these implementations. If you don't have any data, you're returning a list containing { null }. Instead, return an empty list (like the stock experiments do)

public ScienceData[] GetData()
{
    return new ImpactScienceData[] { result }; // if result is null, this chokes up ScienceAlert since it looks like there's data when there is none
}
public ScienceData[] GetData()
{
    return result != null ? new ImpactScienceData[] {result} : Enumerable.Empty<ImpactScienceData>();
}

Low-priority and only noticed because of an oversight in my own code which failed to check GetScienceCount() before calling GetData()