Giter Site home page Giter Site logo

Comments (5)

xilexio avatar xilexio commented on September 16, 2024

I had a look at the code and I think there must be a problem in this general area:

if ((float)dTime - fLastCheck > 43200)
{
float fDays = (((float)dTime - fLastCheck) / 43200);
float fProduced = fDays * fProductionRate;
fCurrent = fCurrent + fProduced;
if (fCurrent > fMax) fCurrent = fMax;
if (sFacilityType == "Research")
{
myResearch.ScienceOCurrent = fCurrent;
}
if (sFacilityType == "Business")
{
myBusiness.FundsOCurrent = fCurrent;
}
facField.GetField("LastCheck").SetValue(selectedFacility.myFacilities[0], (float)dTime);
}

I think there is a bug with time being incorrectly counted when the updates happen too fast. I was expecting something like rounding errors that lead to adding ceil(small float number), but it seems floats are being used. The updating code in the if in L156 looks okay to me though, I'd have to actually compile it to be sure.

from kerbal-konstructs.

xilexio avatar xilexio commented on September 16, 2024

Actually, how about never updating it, just saving the time when the funds were taken last time and just displaying a computed min(maxFunds, days * ratio) every time? That way, the intermediate state would never be there, and you'd only have to store a single value - the time of last withdrawal. That would remove any bug connected to updating funds too often instead of computing them and updating at the point of withdrawal only.

from kerbal-konstructs.

GER-Space avatar GER-Space commented on September 16, 2024

The main problem was. that I pulled the productionrate and set it to the last-check time. And I did it every frame... that why you got the insane amounts of credits and research.

from kerbal-konstructs.

GER-Space avatar GER-Space commented on September 16, 2024

ok, the Code is really a mess. I never really looked into it. I always only made it compile... this time I'm fixing it for real and I will give it reasonable numbers for the investment.

from kerbal-konstructs.

GER-Space avatar GER-Space commented on September 16, 2024

fixed with commit 3fbdf96

from kerbal-konstructs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.