Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes SegFault w/ flashlights & attached power
There was a segfault occuring on https://github.com/CleverRaven/Cataclysm-DDA/blob/master/src/item.cpp#L12277 when turning on a heavy-duty flashlight while it is simultaneously connected to a power source (ie. a vehicle) and does not have a battery. Added: - a short circuit check for ammo to address this issue in the future in case there are any other edge cases where this occurs. - a check for a linked power source so the light source uses the power source's linked power when determining the illumination value. Fixes #78580 Note: I used https://github.com/CleverRaven/Cataclysm-DDA/blob/master/src/item.cpp#L14177 as a reference for the linked power check above. This means the two power checks are extremely similar and it makes me believe that it would be beneficial to have a function such as `has_link_power` that returns a boolean (true for has power, false otherwise). My only hesitation is that I do not know where else that sort of power check is done and what the complete scope of the checks against `charge_rate` / `charge_interval` are for.
- Loading branch information