CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.54k stars 4.16k forks source link

Time compressed activities are slower while carrying/wearing switched on UPS powered items. #47264

Open Quintovir opened 3 years ago

Quintovir commented 3 years ago

Describe the bug

Time compressed activities are slower when carrying/wearing switched on tools and clothes (does not matter if you are wearing them) that have been modified with UPS conversion mods compared to ones using removable batteries for: cellphone (UPS) combat exoskeleton field combat exoskeleton flashlight (UPS) electric blanket (UPS) geiger counter (UPS) "turn continuous scan on" headlamp (UPS) heavy duty exoskeleton heavy duty flashlight (UPS) mp3 player (UPS) laptop computer (UPS) pair of thermal electric gloves (UPS) radio (UPS) "the UPS radio lost the ability to scan for stations" reading light (UPS) smart lamp (UPS) smartphone (UPS) "music and/or light" survivor headlamp (UPS) thermal electric balaclava (UPS) thermal electric outfit (UPS) thermal electric suit (UPS)

All these items share the ability to be manually switched on/off. Using UPS items that are used as needed (soldering iron, arc welder, etc) don't seem to affect the speed of time compressed activities. There's probably other UPS converted/powered items with manual switches that I missed that also cause time compressed activities to slow down.

Steps To Reproduce

  1. Turn on one of the tools listed above.
  2. Wait 30 minutes, disassemble, craft, read, or do some other time compressed activity.
  3. Note how fast time passes.
  4. Shut off the tool you turned on in step 1.
  5. Turn on a copy of the same tool that has a removable battery installed.
  6. Repeat step 2-4.
  7. Compare how fast the time passed while using UPS modded and non-UPS modded tools.

Expected behavior

Compressed activities while carrying/wearing switched on UPS converted tools and clothes should progress the time about as fast as when using switched on tools/clothes using removable batteries.

Screenshots

N/A

Versions and configuration

Additional context

Save game with the mentioned tools in the inventory or on the floor. There are plenty of materials in the vicinity to use.

Champlin.zip

Aivean commented 3 years ago

I can confirm the issue.

Without UPS: image

With UPS: image

The problem appears to be in how UPS charges are consumed: via the crafting inventory, that currently has to be recreated every turn, and which is based on the inventory class that copies items: image

I think the solution would be to replace crafting inventory with the new lightweight class temp_crafting_inventory (introduced in #46286). To reduce the scope, as a temporary solution, instead of replacing crafting_inventory everywhere, it can only be replaced inside the Character::use_charges method.

Alternative approach could be to add separate cache for USP items near the player that could be used by Character::use_charges method.

Aivean commented 3 years ago

Seems to be caused by/related to #45781

Hirmuolio commented 3 years ago

48608 should help with this.