Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raw cookies per second is set to a very high value on initial load #19

Closed
erbkaiser opened this issue Jun 14, 2022 · 10 comments
Closed
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@erbkaiser
Copy link
Owner

Something in the code is causing Game.cookiesPsRawHighest (highest raw cookies per second this ascension) to be set to 70.4 quadrillion even in an empty save with everything disabled.
This messes with the stock market as it's based on the highest value ever for that save.

Setting Game.cookiesPsRawHighest to zero in the FC loader does not solve this, it seems to happen shortly after load. Nothing is shown in the console.

@erbkaiser erbkaiser added bug Something isn't working help wanted Extra attention is needed labels Jun 14, 2022
@erbkaiser
Copy link
Owner Author

erbkaiser commented Jun 17, 2022

This bug exists (with a different value for cookiesPsRawHighest) in upstream, too, so it's not new to this fork.

That the value changed with my fork might suggest it's something with the efficiency calculations as those run regardless of any other functions being active, and with my fork more upgrades are being tracked.

@erbkaiser erbkaiser changed the title Raw cookies per second is set to 70.4 quadrillion on load Raw cookies per second is set to a very high value on initial load Jun 18, 2022
@Darkroman
Copy link

Even the OG FC by Icehawk78 gives a number of 8.3 quadrillion cookiesPsRawHighest. I believe I have pinpointed through tedious debugging and stepping that it happens upon the line var reverseFunctions = upgradeToggle(current); in the function upgradeStats(recalculate). When I step over next function call on that line, the cookiesPs value itself changes constantly from 0.5 to 1 to 2 to 2.5 to 5 and 10 and I think it just keeps building over time. I'm gonna do individual steps now upon that line and I'll see if I notice where the change exactly occurs in the program.

@Darkroman
Copy link

Darkroman commented Jun 21, 2022

Seems to happen within whatever it does in Game.CalculateGains() when it is called in fc_main.js on line 3074 (in your fork). Trying to pinpoint within that call exactly hasn't been easy. More updates coming soon.

@Darkroman
Copy link

I'm stumped. Been at this for a while now. I don't know if it has to do with how FC is just built (I'm not very good in JS I'll be honest). I've gotten it down to where I add breakpoints on lines 3074 in your fork, and 5078 within the actual game code. I was watching for these variables:
Game.cookiesPsRawHighest
Game.cookiesPs
baseCPS()
cpsNew
me.storedTotalCps
me.storedCps
me.amount
me.cps(me)

Perhaps you'll have better luck. It might have something to do with the upgradeStats(recalculate) function as well. My brain is shot for the moment.

@erbkaiser
Copy link
Owner Author

Good research.
I suspect that because function upgradeToggle (line 3009) actually does a reverse lookup of what it needs to unlock the buildings and upgrades it causes cookiesPsRawHighest to get set somewhere.

It might have to do with vanilla line 15106 onwards, //experimental debugging function that cycles through every owned upgrade, turns it off and on, and lists how much each upgrade is participating to CpS

@Darkroman
Copy link

Darkroman commented Jun 21, 2022

So it has to do with FC setting building.amount (for some reason, no idea) and it using that value I believe when iterating through. Reverse function just kinda reverses it back to what it should be. Even in saved games with quintillion prestige and rocking 64 septillion cps, the cookiesPsRawHighest is set slightly higher than it should be. Honestly with how the code was stepping, a good fix would be to somehow do Game.CalculateGains() ONLY AFTER the reverse function has done its job.

Perhaps switch the placement of Game.CalculateGains() to be after return reverseFunctions on line 3074? I would do my own testing but for some reason my fork from yours isn't loading up.

@Darkroman
Copy link

Scratch that, scratch all of that. We need Icehawk to fix this lol. The way it works is deeply built into FC. It'd practically require a rewrite of how it gets all the information needed for the efficiency and next purchase listings.

@erbkaiser
Copy link
Owner Author

erbkaiser commented Jun 21, 2022

To test your fork you need to setup pages for it and have it served from darkroman.github.io or your own domain if you have one (or from a local jekyll install). Your frozen_cookies.js is now pointing to https://github.darkroman.com/, which does not exist.

I did a bit of testing with my local web server build and I think you're right, this is so deep in the code t would require a full rewrite of the efficiency calculations, which is beyond my current Javascript skill.

The only workaround I found is to force run a delayed Game.cookiesPsRawHighest = 0, about 30s after initial load, but this of course deletes the actual cookiesPsRawHighest for running games.

I am probably going to close this as wontfix as a known issue, since it's just not feasible to do a full rewrite ☹️

@erbkaiser erbkaiser added wontfix This will not be worked on and removed help wanted Extra attention is needed labels Jul 2, 2022
@erbkaiser
Copy link
Owner Author

Labelling this as wontfix and closing. It's tied deeply in how FC works and would basically require rewriting a huge part of the mod, only to lose the accurate efficiency calculations.

@erbkaiser erbkaiser closed this as not planned Won't fix, can't repro, duplicate, stale Jul 2, 2022
@erbkaiser erbkaiser pinned this issue Jul 2, 2022
@erbkaiser
Copy link
Owner Author

Root issue: Icehawk78#217

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants