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

CPU functions returning invalid data #39

Open
shanemadden opened this issue Feb 29, 2024 · 0 comments
Open

CPU functions returning invalid data #39

shanemadden opened this issue Feb 29, 2024 · 0 comments

Comments

@shanemadden
Copy link
Contributor

For user code, Game.cpu.getUsed() returns NaN which seems to also be corrupting bucket data.

Steps to reproduce: after starting a server and resetting its data, get spawned in and set this main module code as the whole bot:

module.exports.loop = function () {
  console.log(`cpu used ${Game.cpu.getUsed()}, ${JSON.stringify(Game.cpu)}`);
}

This results in the output: cpu used NaN, {"tickLimit":100,"limit":100,"bucket":0} each tick; the bucket number never accumulates.

In the database, the user's bucket value (cpuAvailable) is NaN, as well as a couple other CPU values:

storage.db["users"].findOne({ username: "bot" })
{
  #...(snipped irrelevant fields)...
  cpu: 100,
  cpuAvailable: NaN,
  active: 10000,
  lastUsedCpu: NaN,
  lastUsedDirtyTime: NaN,
}

Setting cpuAvailable to an integer value has no apparent effect and seems to be written back to NaN on next tick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant