cataclysmbnteam / Cataclysm-BN

Cataclysm: Bright Nights, A fork/variant of Cataclysm:DDA by CleverRaven.
https://docs.cataclysmbn.org
Other
696 stars 272 forks source link

power_draw off by a factor of 10 #1203

Closed chaosvolt closed 2 years ago

chaosvolt commented 2 years ago

Describe the bug

As noted in testing of https://github.com/cataclysmbnteam/Cataclysm-BN/issues/1165, the power_draw function is broken in an unusual way, consuming roughly 10% the power it implies it's supposed to.

Power is supposed to be in milliwatts according to the documentation, so I would assume this is an unexpected consequence of https://github.com/cataclysmbnteam/Cataclysm-BN/pull/1071. Problems here are:

  1. I don't recall if any of the functions changed actually link power_draw to the joule units.
  2. If so, shouldn't it be off by a factor of 1000, not 10?

You would expect that telling it "1 millijoule = 1 joule now literally only for save compatibility because characters with zero power stored it as 0 mJ for some awful reason" would make it try to consume 1 watt for every milliwatt specified.

Steps To Reproduce

  1. Spawn in a standard item autoclave
  2. Load it with a battery with 8200 or more charges (most likely only a heavy plutonium battery will do).
  3. Activate it to sterilize a CBM.
  4. Wait 90 minutes.
  5. Observe that it took something closer to 820 charges, not 8200.

Expected behavior

For it to either:

  1. For it to correctly hoover up some number close to 8200 kJ of power.
  2. To make autoclaves even more annoying than intended by trying to hoover up 8200000 kJ of power, if it's caused by the joule conversion PR.

Screenshots

image

Versions and configuration

EDIT: On further testing this problem seemed to crop up with an earlier build and not the one initially posted here, will likely close this if I can't reproduce this with most recent build.

Additional context

Dropping power_draw in favor of the normal turns per charge method might be a viable quickfix since power_draw is only used by a handful of items, and the whole "in the neighborhood of X kJ eaten up" indicates it isn't any less wonky than turns_per_charge even when it works right.

Alternatively, tacking an extra zero onto every instance of power_draw in use would also be a quickfix, and keeping the power_draw function does have the sole advantage of letting use specify usage higher than a kilowatt (as by definition turns_per_charge limits it to 1 kJ burned every second, or 1 kW).

On the other hand, large space heaters cap out at 1 kW despite 1500-watt heaters being ubiquitous in the US, and autoclaves should get their power consumption toned down to something less wacky eventually anyway...

chaosvolt commented 2 years ago

Okay I just tested this in said build again and I'm getting the expected power draw now: image

It was definitely broken in a previous build, let me make sure to grab latest build and test it some more.

chaosvolt commented 2 years ago

Closing as this was evidently an old-build issue, it's working fine now.