Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement integral magazines as magazine items #32331

wants to merge 68 commits into
base: master


Copy link

commented Jul 12, 2019


SUMMARY: Infrastructure "Reimplement integral magazines as MAGAZINE items"

Purpose of change

Several areas of code can be simplified if they only have to consider magazines as ammo sources.

Part of #32227.

Describe the solution

Integral magazine loadables are defined for an object as described in #32227. While new code in this branch is written to support more than one magazine, most of the existing code is not so until all relevant code is updated no more than one integral magazine should be defined per item. There should be no significant player visible changes from this PR.

  • Define integral magazine loadables
  • Generate integral magazines in item's contents when it is created
  • Update item::info to display information appropriately for integral magazines
  • Update relevant reloading code for new system
  • Update unloading code to block removing integrals
  • Respect RELOAD_ONE for magazines
  • Update reloading code to allow speedloaders and clips to be used for reloading magazines
  • Ensure STR_RELOAD and RELOAD_EJECT work with integral magazine items
  • Implement integral magazines in gunmods as in guns
  • Implement integral magazines in tools as in guns
  • Write unit tests for reloading and magazine handling code
  • Document new JSON
ymber added 12 commits Jul 12, 2019
Update is_reloadable helper for integral mags
item::is_reloadable_helper should only be checking whether the itype_id
it is given can be reloaded into the specific item it is called from
and not any items in that item's contents. As integral magazines are
now separate items to the items they provide ammo for, the only
reloadable item types are now watertight containers and magazines,
as well as items that can be reloaded with detachable magazines.
item::is_reloadable_helper now handles these three cases.
src/item_factory.cpp Outdated Show resolved Hide resolved
src/item_factory.cpp Outdated Show resolved Hide resolved
src/item.cpp Outdated Show resolved Hide resolved
src/item.cpp Outdated Show resolved Hide resolved
ymber added 11 commits Jul 13, 2019
Update item::is_reloadable_helper for speedloaders
A speedloader may be used to reload an item if some conditions are met.
 - The item being loaded must be a magazine.
 - The item being loaded must be empty.
 - The item being loaded must list the speedloader in its clips array.
Usual conditions of ammo availability etc apply.
ymber added 27 commits Jul 16, 2019

@ymber ymber force-pushed the ymber:integral_mags branch from 63ac433 to 9d0d7c3 Jul 19, 2019


This comment has been minimized.

Copy link

commented Aug 17, 2019

Excited for this since as you'd mentioned on discord, this should let many guns fire without magazines (emulating the chamber)


This comment has been minimized.

Copy link

commented Sep 10, 2019

This pull request has been mentioned on Cataclysm: Dark Days Ahead. There might be relevant details there:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
5 participants
You can’t perform that action at this time.