Skip to content

CPU functions returning invalid data #39

@shanemadden

Description

@shanemadden

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions