Nebula icon indicating copy to clipboard operation
Nebula copied to clipboard

Make ammo magazines lazy-initialize

Open out-of-phaze opened this issue 1 year ago • 2 comments

Description of changes

Do not merge, needs additional testing and maintainer consensus on if this is something we even want to do. Could also make it a config or compile option if desired.

Most ammo magazines will now wait until their first interaction (with their contents, not necessarily by players) to create their contents. Chambering/consuming a round from an uninitialized magazine will lower the initial ammo count by one and create exactly one round, further delaying initialization where possible.

Why and what will this PR improve

Cuts off a decent amount of init time by waiting to create objects that functionally don't exist until interacted with already.

Changelog

:cl: experiment: Ammo magazines will not initialize their contents until first interacted with, which makes startup faster but could cause bugs. Report any issues on the issue tracker! /:cl:

out-of-phaze avatar Feb 24 '24 03:02 out-of-phaze

I almost feel like it would be preferable for mags to never instantiate their full contents - outside of people manually loading in shells, we only ever care about the same time 50 times or whatever, which could be factored into worth and matter calc pretty easily without creating the full set.

MistakeNot4892 avatar Feb 27 '24 07:02 MistakeNot4892

It should only generate them all when you dump out the magazine or do other things that access all of them, iirc? I was pretty careful to delay instantiation as much as possible.

out-of-phaze avatar Feb 27 '24 16:02 out-of-phaze