Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upUnified item mods #18735
Conversation
mugling
force-pushed the
mugling:toolmod
branch
to
1ac1149
Oct 11, 2016
mugling
added some commits
Oct 11, 2016
mugling
force-pushed the
mugling:toolmod
branch
to
09e9d78
Oct 11, 2016
mugling
added some commits
Oct 11, 2016
mugling
changed the title
Unified item mods [WIP]
Unified item mods
Oct 11, 2016
mugling
added some commits
Oct 11, 2016
This comment has been minimized.
This comment has been minimized.
|
Ready |
mugling
added some commits
Oct 12, 2016
This comment has been minimized.
This comment has been minimized.
|
Could this be fixed? #18739 |
This comment has been minimized.
This comment has been minimized.
Unrelated to this PR |
Coolthulhu
self-assigned this
Oct 12, 2016
This comment has been minimized.
This comment has been minimized.
|
Has a conflict with #18514 - looks trivial, just a string change. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
And then segfault during migration. |
This comment has been minimized.
This comment has been minimized.
|
Will look into. I don't suppose you have a stack trace? |
This comment has been minimized.
This comment has been minimized.
|
Fixed (099a8cf) by removing the useless entry to |
This comment has been minimized.
This comment has been minimized.
Expected:
Got:
|
This comment has been minimized.
This comment has been minimized.
|
Known limitation to avoid transmutation of ammo. If it's essential we could add an implicit unload step but I'd prefer to wait for #18514 and then write an implementation complete with denial reasons? |
This comment has been minimized.
This comment has been minimized.
|
Old implementation allowed it. |
This comment has been minimized.
This comment has been minimized.
|
Fixed |
This comment has been minimized.
This comment has been minimized.
|
Atomic mod lost a 0 in multiplier - it's 10 times capacity, was 100. |
This comment has been minimized.
This comment has been minimized.
Intentional although I'm not especially attached to that if you disagree |
mugling
added some commits
Oct 12, 2016
This comment has been minimized.
This comment has been minimized.
|
Atomic batteries are incredibly expensive compared to regular ones, them having "infinite" capacity makes them less useless. |
This comment has been minimized.
This comment has been minimized.
Ok, fixed |
Coolthulhu
merged commit 400ac9b
into
CleverRaven:master
Oct 12, 2016
Coolthulhu
reviewed
Oct 12, 2016
| @@ -3558,6 +3559,11 @@ bool item::is_wheel() const | |||
| return type->wheel.get() != nullptr; | |||
| } | |||
|
|
|||
| bool item::is_toolmod() const | |||
| { | |||
| return !is_gunmod() && type->mod; | |||
This comment has been minimized.
This comment has been minimized.
Coolthulhu
reviewed
Oct 12, 2016
| std::set<ammotype> acceptable_ammo; | ||
|
|
||
| /** If set modifies parent ammo to this type */ | ||
| ammotype ammo_modifier = NULL_ID; |
This comment has been minimized.
This comment has been minimized.
Coolthulhu
Oct 12, 2016
Contributor
Shit, I merged it because it didn't crash on my build, but NULL_ID in unspecified context (possibly static) is still unsafe.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
mugling
Oct 12, 2016
•
Author
Contributor
I think it wasn't change though from the original?
EDIT: Yes, it wasn't changed
This comment has been minimized.
This comment has been minimized.
mugling
Oct 12, 2016
Author
Contributor
What are the rules about NULL_ID. We need to get that fixed for 0.D?
This comment has been minimized.
This comment has been minimized.
Coolthulhu
Oct 12, 2016
Contributor
NULL_ID must never be used in context that can be static.
Static initialization is not guaranteed to happen in any order other than those specified for single file.
For example, on Cygwin (just an example), the sort order of files seems totally scrambled.
I think it's the link order which determines static initialization order. There are ways to guarantee static initialization order, but they most likely depend on very specific linking which would be a pain to keep.
Would probably be better to just drop the static NULL_ID and wrap it in a getter. We had a PR like this and I think I stalled it, but I can't think of a better way to do it.
We could keep the null id type for that weird overload trick, but it should no longer point to possibly-valid object.
Coolthulhu
reviewed
Oct 12, 2016
| static const std::vector<std::string> removable_mods = {{ | ||
| "DOUBLE_AMMO", "USE_UPS", "ATOMIC_AMMO" | ||
| }}; | ||
| if( !p ) { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
mugling
Oct 12, 2016
•
Author
Contributor
Only because we hacked around that. Theres a code comment somewhere about wanting to drop that precondition
This comment has been minimized.
This comment has been minimized.
Coolthulhu
Oct 12, 2016
Contributor
Would be much better to hand it over to a null character anyway.
This comment has been minimized.
This comment has been minimized.
mugling
Oct 12, 2016
Author
Contributor
True. I want to rework iuse to use an item_location. What would a good function signature look like?
This comment has been minimized.
This comment has been minimized.
Coolthulhu
Oct 12, 2016
Contributor
Character &user, item &it, bool t, const tripoint &pos
If using item_location, you should first guarantee that the supplied location:
- Always points to a valid item (this should never need to be checked in the iuses)
- Can be accessed in constant time almost always (ie. unpacking would be done only for the first time)
remove_itemis never invoked during processing. Otherwise the active item vectors would get scrambled and the function itself could segfault.
So overall it would be better to keep it without location. If we want location, it would be better to keep an item map and give items some sort of id - it would be more work at start, but would most likely end up less work in total.
This comment has been minimized.
This comment has been minimized.
mugling
Oct 12, 2016
Author
Contributor
remove_item could remove the item from the active item vectors. One of the reasons I want to use item_location is that it makes vehicle mounted tools or interaction with static furniture much easier.
This comment has been minimized.
This comment has been minimized.
Coolthulhu
Oct 12, 2016
Contributor
Now that would lead to a giant mess, as active item processing would need to understand being tampered with in the middle of iteration.
Coolthulhu
reviewed
Oct 12, 2016
| p->add_msg_if_player( m_info, _( "You do not have that item!" ) ); | ||
| // can remove mods from unloaded tools only | ||
| auto filter = []( const item &e ) { | ||
| return !e.toolmods().empty() && !e.ammo_remaining() && !e.magazine_current(); |
mugling commentedOct 11, 2016
•
edited
Provides the groundwork for #17008 by implementing a
TOOLMODtype. The design is intentionally very simple - only one mod can be installed at once and the only possible restrictions are per ammo type. We don't want nor need anything as complex as theGUNMODmess.iusefunctions withiuse::toolmod_attachDOUBLE_AMMOandATOMIC_AMMOflagsweightandvolume/volume_integralThe purpose of this PR is to cleanup
core- not to expand the range of tool mods (although mod authors may wish to do so). The following fields are supported:acceptable_ammoammo_modifiercapacity_multipliermagazine_adaptorflagsThe radio activation mod could probably also later be converted to use this functionality (separate PR)