ShotgunNinja / Kerbalism

Hundreds of Kerbals were killed in the making of this mod.
The Unlicense
43 stars 19 forks source link

Crew bonus miscalculated for background processing of converters which don't use crew #169

Open gbesacier opened 6 years ago

gbesacier commented 6 years ago

From my tests, it seems converters which don't use crew bonus are 80% slower during the background processing than during non-timewrap.

I think the problem is here: https://github.com/ShotgunNinja/Kerbalism/blob/df950e24872712f1ecc3be3545c4b74a913913b4/src/Background.cs#L239

Replace with:

        double exp_bonus = 1;
        // deduce crew bonus
        if (converter.UseSpecialistBonus)
        {
          int exp_level = -1;
          foreach(ProtoCrewMember c in Lib.CrewList(v))
          {
            if (c.experienceTrait.Effects.Find(k => k.Name == converter.ExperienceEffect) != null)
            {
              exp_level = Math.Max(exp_level, c.experienceLevel);
            }
          }
          exp_bonus = exp_level < 0
            ? converter.EfficiencyBonus * converter.SpecialistBonusBase
            : converter.EfficiencyBonus * (converter.SpecialistBonusBase + (converter.SpecialistEfficiencyFactor * (exp_level + 1)));
        }

exp_bonus is always 1 if the part does not use crew.