Open IdleSol opened 4 weeks ago
The .h file is just the header file, where the functions and classes are declared. To see what's actually happening in the functions, you want to check the .cpp file.
The relevant lines to MOLLE are 4158 to 4228. I'll be honest, I don't really know c++, but glancing through these I see a function that loads the size and move values in from the json file and assigns them for use in other functions.
void molle_attach_actor::load( const JsonObject &jo, const std::string & )
{
assign( jo, "size", size );
assign( jo, "moves", moves );
}
Then the next function seems to be the meat of actually attaching the pocket
std::optional<int> molle_attach_actor::use( Character *p, item &it,
const tripoint & ) const
{
if( !p ) {
debugmsg( "%s called action molle_attach that requires character but no character is present",
it.typeId().str() );
return std::nullopt;
}
` item_location loc = game_menus::inv::molle_attach( *p, it );`
if( !loc ) {
p->add_msg_if_player( _( "Never mind." ) );
return std::nullopt;
}
` item &obj = *loc.get_item();` ` p->add_msg_if_player( _( "You attach %s to your MOLLE webbing." ), obj.tname() );`
it.get_contents().add_pocket( obj );
` // the item has been added to the vest it should no longer exist in the world` ` loc.remove_item();`
return 0;
}
So I believe it.get_contents().add_pocket( obj );
would be the actual function call that attaches the pocket obj
to the item it
, and the size value would be dealt with in that function? The rest of this function seems to just be setting up for this call, error checking, and text display. Then it removes the original item at the end. I had a cursory glance through some other files trying to find where that function was defined but have to go to work now.
Again, I don't know c++, so all of this is just trying to parse the code using what I know from other languages, so hopefully someone else with real c++ knowledge can come tell me why I'm wrong and how this actually works that would be great xD
Edit: add_pockets is declared in item_contents.h on line 217, and defined in item_contents.cpp on line 2134. Looks like this just handles the migration of the items though. I can't find where the moves variable is actually used, if it is.
Now that I'm a bit more awake, I'd that moves variable not the moves to put an item in or take one out of the pocket?
The number of moves to attach a pocket or vice versa to detach a pocket from something.
If it is that, then I don't believe this variable is currently used based on what I've seen from the functions I mention in my previous comment.
Describe the bug
Or did I just not find it? I need an example with all possible parameters. And explanations for them.
If you look at the realized things:
Are these all the parameters that can be used? Or is it possible to use, for example:
moves
?Attach save file
n/a
Steps to reproduce
n/a
Expected behavior
Adding a description to the documentation.
Screenshots
No response
Versions and configuration
master
Additional context
https://github.com/CleverRaven/Cataclysm-DDA/blob/70cffec6ac580674136196b5d85869cad5abbf28/src/iuse_actor.h#L1017-L1020
I don't understand anything about programming. Does this mean you can set the number of moves, for attaching a pocket? I have tried setting it. The game loads without errors, but does not spend time to attach the pocket.
Is this a mistake or is it intended to be?